-
Notifications
You must be signed in to change notification settings - Fork 381
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
feat: Minimize contention in Bigtable Client initialization. #2923
Conversation
Channel pools for Bigtable clients are lazy initialized, the first thread that needs them creates them. To avoid deadlocks and unbound priority inversions this thread releases the locks while creating the pools, and relocks before saving the newly created pool. In some cases two (or more) threads may create the pool, in this case the pool created by the second thread is discarded. We were discarding this work with the lock held, which resulted in deadlocks for some users inside Google (this should not affect external users).
Codecov Report
@@ Coverage Diff @@
## master #2923 +/- ##
==========================================
- Coverage 90.75% 90.68% -0.08%
==========================================
Files 297 297
Lines 19943 20007 +64
==========================================
+ Hits 18100 18144 +44
- Misses 1843 1863 +20
Continue to review full report at Codecov.
|
} else { | ||
// Some other thread created the pool and saved it in `stubs_`. The work | ||
// in this thread was superfluous. We release the lock while clearing the | ||
// channels to minimize contention, this seems to workaround other bugs |
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.
s/contention, this/contention. This/
Although, I'm not sure the "seems to workaround" part is useful. I'm not even sure what "the Google implementation of std::mutex" is referring to.
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.
I'm still not sure what "bugs inside Google" means, but you can fill me in later.
Channel pools for Bigtable clients are lazy initialized, the first
thread that needs them creates them. To avoid deadlocks and unbound
priority inversions this thread releases the locks while creating the
pools, and relocks before saving the newly created pool.
In some cases two (or more) threads may create the pool, in this case
the pool created by the second thread is discarded. We were discarding
this work with the lock held, which resulted in deadlocks for some
users inside Google (this should not affect external users).
This change is