1

Right now I am preventing several users from several instances to access the same row of my database table with a PESSIMISTIC_WRITE lock. The transaction which locks the row has the default isolation level set which is REPEATABLE_READ.

Under the circumstance that the table is empty it gets refilled with new entries and here it gets strange. The insert is an async bulk insert that runs in a seperate transaction. So when this data is commited a users reads a row for update which should lock the row. Somehow this does not work anymore and several users are able to get the value from the same row.

While trying to figure this out I changed the isolation level to READ_COMMITED and the issue did not occure anymore.

Can somebody enlighten me how this is possible? What am I missing?

Here is some psyeudo code for better understanding:

Async refilling

Transaction
get values to insert
bulk insert

Getting values

Transaction
read a row for update (Locks it)
do stuff
delete the row

For locking we are using this annotation from spring data: @Lock(LockModeType.PESSIMISTIC_WRITE)

4

1 回答 1

0

好的,答案是,极光 2.x 之前的极光使用的是 MySQL 5.6.10。Aurora 2.x 现在使用 MySQL 5.7.12,这个问题是一个现已修复的错误。

PS 我还在问自己为什么 aurora 使用 2 年前的 MySQL 版本,但那是另一回事。

于 2018-05-08T07:12:02.753 回答