MySQL second connection does not see committed change from first connection

蓝咒 提交于 2019-12-13 04:05:41

问题


I have a problem with a Grails based application that is connected to MySQL where there is a process that updates a record as part of a larger transaction. This process also kicks off a 2nd thread via a Quartz job that will perform some additional changes. The Quartz job typically starts before the first thread commits the transaction therefore the job loops up to one minute checking for the record to change to the expected state. Oddly it works consistently in some environments, fails consistently in one and infrequently in yet another.

My question has to do with how MySQL recognizes transaction commits between two concurrent connections. One would expect that when connection A performs the commit, that subsequent queries from connection B would recognize the committed change. In my case connection B will have made the same query one or more times before connection A has made the commit. It appears that mySQL is caching the query results for the connection. Oddly enough, while connection B is repeatedly querying and getting the old value, I can issue the same query via the mysql client and see the new value. Does anyone aware of a caching issue or concurrency issues?

For the above observation I have the MySQL log enabled in order to see the individual update, commits and queries occurring.

The various environments are using different versions of MySQL as shown below. I'm in the process of upgrading my environments to the latest MySQL to see if that resolves it.

5.0.51a - two environments that have been very stable with infrequent occurrences however one environment started having increased occurrences over the weekend with moderate traffic.

5.1.55 - one environment consistently fails

Thanks,

John

来源:https://stackoverflow.com/questions/16018702/mysql-second-connection-does-not-see-committed-change-from-first-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!