-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
bugfix: ensure select for update retry correctly #1452
bugfix: ensure select for update retry correctly #1452
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1452 +/- ##
=============================================
- Coverage 45.69% 45.67% -0.02%
Complexity 1664 1664
=============================================
Files 345 345
Lines 12673 12673
Branches 1593 1593
=============================================
- Hits 5791 5789 -2
- Misses 6234 6235 +1
- Partials 648 649 +1
Continue to review full report at Codecov.
|
@ggndnn good found. Does it work if the db's isolation level is set to repeatable read? |
@slievrly I think it works. Because select-for-update statement returns current latest data in db, event set to repeatable read level, not like normal select statement who may query data from snapshot. |
@ggndnn Before the code is modified: |
@slievrly Though X lock is hold, but it is released by
|
So, I think conn.rollback(sp) is executed when the last retry is unsuccessful, instead of going to rollback every time. |
@ggndnn After considering I think your plan is more appropriate. Because if I follow my plan, I got the X lock of the database and didn't get the global lock. At the same time, another distributed transaction gets the global lock and releases the database lock. When it wants to perform the globalRollback, it will cause deadlock. |
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.
LGTM
@slievrly Thanks for your review. |
b45c037
to
a8cd02e
Compare
According to the currently modified code, this understanding is correct. The current |
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.
okey to me
Ⅰ. Describe what this PR did
In
SelectForUpdateExecutor
, select-for-update statement is not in global locking retry loop, so the data read is not necessarily globally committed. This PR ensue select-for-update retry correctly.Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews