This repository was archived by the owner on Sep 26, 2023. It is now read-only.
fix: Fix race condition in BatcherImpl flush#1200
Merged
igorbernstein2 merged 2 commits intogoogleapis:masterfrom Oct 5, 2020
Merged
fix: Fix race condition in BatcherImpl flush#1200igorbernstein2 merged 2 commits intogoogleapis:masterfrom
igorbernstein2 merged 2 commits intogoogleapis:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1200 +/- ##
=========================================
Coverage 79.06% 79.07%
- Complexity 1197 1198 +1
=========================================
Files 205 205
Lines 5268 5270 +2
Branches 435 436 +1
=========================================
+ Hits 4165 4167 +2
Misses 930 930
Partials 173 173
Continue to review full report at Codecov.
|
miraleung
approved these changes
Oct 5, 2020
vam-google
approved these changes
Oct 5, 2020
Contributor
vam-google
left a comment
There was a problem hiding this comment.
LGTM, but how painful will it be to add a test for that?
Contributor
Author
|
I think a test would be quite difficult, but I can try in a separate PR. This is currently a blocker for a customer, so I'd prefer to get this out asap. Would it be possible to cut a release with this change either today or tomorrow? |
Contributor
Author
|
Added a stress test..wasnt as bad as I expected |
35fe8fb to
1ec3428
Compare
Currently the following race condition exists: T1 - awaitAllOutstandingBatches checks that numOfOutstandingBatches > 0 T2 - onBatchCompletion decrements numOfOutstandingBatches T2 - flushLock.notifyAll() T1 - flushLock.wait() so T1 will wait indefinitely The fix is quite simple: make sure that the there batches to wait for after acquiring the lock
1ec3428 to
ebad62f
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the following race condition exists:
T1 - awaitAllOutstandingBatches checks that numOfOutstandingBatches > 0
T2 - onBatchCompletion decrements numOfOutstandingBatches
T2 - flushLock.notifyAll()
T1 - flushLock.wait()
so T1 will wait indefinitely
The fix is quite simple: make sure that the there batches to wait for after acquiring the lock