-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESI-11623 perform locking fetch on Delete operation #477
Conversation
0716864
to
1fd30c9
Compare
Could you add an example for this? The result seems same for both serialization level for me. |
@nati , You're right. SERIALIZABLE Selects don't use consistent snapshot. The issue still occurred, though. Exact scenario is following:
I've checked manually and 4 doesn't fail for SERIALIZABLE (LOCK IN SHARE MODE finds newly inserted rows), while it obviously fails for REPEATABLE READ. This points to a conclusion that in MySQL driver, Transaction Isolation Level is not properly set. This is strange, because after fix #458 we no longer do it incorrectly manually (which causes TX levels to be pretty much random), but instead use standard library to do it. Documentation doesn't mention it, but it seems it silently fails to apply TxOptions if driver doesn't implement new interface (checked in runtime) and falls back to oldBegin() if context is root (this validation should be before this if). Vendored go-mysql library doesn't support new
In any case, I think this PR is still needed for cases where transaction is not Serializable (e.g. custom actions can create any type of transaction). |
8dfbf0c
to
0f62b43
Compare
it sounds like you are simulating the behavior of SERIALIZED on REPEATABLE READ by some coding. Why not just use serializable? |
@nati , Even when SERIALIZABLE is fixed for CUD actions, on rare occasions it's better to use REPEATABLE READ, when writing (e.g. we need to perform some aggregation and we have no need to lock all the related rows). This commit is only required for such rare cases. Also, aside from other considerations, this PR is overall improvement (pre-fetch follows same locking rules as delete). |
I supposed that one was fixed on some PR.. let's fix it. I'm not still seeing any difference between applying SERIALIZABLE for delete transaction. |
@nati ,
Which is not true as explained above. @zimnx is adding |
@nati , FYI go-sql-driver/mysql#619 |
In any case, I still think we should merge this PR regardless. There is no guarantee that delete operation will be performed in Serializable transaction (e.g. custom actions). |
Transaction Commit Informer performs a fetch before deleting resource. In order to have consistency and not race consistent snapshot with committed data. E.g: TX1 is REPEATABLE READ TX1 Makes some unrelated SELECTS (consistent snapshot established) TX2 Inserts row X into table test and commits TX1 SELECTS FOR UPDATE a couple of rows, including newly inserted X TX1 Decides to DELETE X, but fails with Not Found (X doesn't exist in consistent snapshot).
306d69d
to
66c6898
Compare
@nati , FYI, we've switched from SERIALIZABLE to READ_COMMITTED, as we've had too many problems with deadlocks caused by Read Locks. |
@marcin-ptaszynski please rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok got it. LGTM
@marcin-ptaszynski This PR seems to be very old and does not merge. Could you resolve the conflicts? |
Transaction Commit Informer performs a fetch before deleting resource.In order to have consistency and not race REAPEATABLE_READ view and
READ_COMMITED view when mixing locking and non-locking SELECTS in
SERIALIZABLE transactions.
Transaction Commit Informer performs a fetch before deleting resource.
In order to have consistency and not race consistent snapshot with
committed data. E.g:
TX1 is REPEATABLE READ
TX1 Makes some unrelated SELECTS (consistent snapshot established)
TX2 Inserts row X into table test and commits
TX1 SELECTS FOR UPDATE a couple of rows, including newly inserted X
TX1 Decides to DELETE X, but fails with Not Found
(X doesn't exist in consistent snapshot).