-
Notifications
You must be signed in to change notification settings - Fork 3.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
sql: resolve deadlock in waitForCacheState #29291
Conversation
@andreimatei do you have any comments for this PR? Thanks |
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
Reviewable status:
complete! 0 of 0 LGTMs obtained
pkg/sql/database.go, line 257 at r1 (raw file):
This method never goes to the store to resolve // the name to id mapping.
Returns 0 if the name to id mapping or the database descriptor are not in the cache.
change cockroachdb#25313 introduced getDatabaseID as the callback used in waitForCacheState. However, waitForCacheState holds on to a lock while calling its callback and can get stuck on an intent written by another transaction. The other transaction having written an intent can be trying to acquire the databaseCacheHolder lock, resulting in the system getting stuck in a deadlock. Originally, the deadlock was thought to be cause by another bug which got fixed through cockroachdb#28381, but now we know of an actual legitimate situation in which the deadlock can happen. The fix is to use another callback that will fix cockroachdb#25313 while not going to the store. fixes cockroachdb#29090 Release note: None
8e7593a
to
3297375
Compare
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.
TFTR!
Reviewable status:
complete! 0 of 0 LGTMs obtained
pkg/sql/database.go, line 257 at r1 (raw file):
Previously, andreimatei (Andrei Matei) wrote…
This method never goes to the store to resolve // the name to id mapping.
Returns 0 if the name to id mapping or the database descriptor are not in the cache.
Done.
bors r=andreimatei |
👎 Rejected by code reviews |
bors r+ |
Build failed (retrying...) |
29291: sql: resolve deadlock in waitForCacheState r=vivekmenezes a=vivekmenezes change #25313 introduced getDatabaseID as the callback used in waitForCacheState. However, waitForCacheState holds on to a lock while calling its callback and can get stuck on an intent written by another transaction. The other transaction having written an intent can be trying to acquire the databaseCacheHolder lock, resulting in the system getting stuck in a deadlock. Originally, the deadlock was thought to be cause by another bug which got fixed through #28381, but now we know of an actual legitimate situation in which the deadlock can happen. The fix is to use another callback that will fix #25313 while not going to the store. fixes #29090 Release note: None Co-authored-by: Vivek Menezes <vivek@cockroachlabs.com>
Build succeeded |
change #25313 introduced getDatabaseID as the callback
used in waitForCacheState. However, waitForCacheState holds
on to a lock while calling its callback and can get stuck
on an intent written by another transaction. The other
transaction having written an intent can be trying to acquire
the databaseCacheHolder lock, resulting in the system getting
stuck in a deadlock.
Originally, the deadlock was thought to be cause by another
bug which got fixed through #28381, but now we know of
an actual legitimate situation in which the deadlock
can happen.
The fix is to use another callback that will fix #25313
while not going to the store.
fixes #29090
Release note: None