Limit to single inflight package syncing operation#289
Merged
tigrannajaryan merged 12 commits intoAug 29, 2024
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #289 +/- ##
==========================================
+ Coverage 76.32% 76.89% +0.56%
==========================================
Files 25 25
Lines 1681 1692 +11
==========================================
+ Hits 1283 1301 +18
+ Misses 291 285 -6
+ Partials 107 106 -1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
tpaschalis
force-pushed
the
single-package-syncing
branch
from
June 30, 2024 16:29
88b2071 to
8fec037
Compare
Member
Author
|
I've rebased main and fixed the conflict from a recent PR, let me know what you think! 🙌 |
srikanthccv
reviewed
Jul 2, 2024
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
srikanthccv
reviewed
Jul 3, 2024
srikanthccv
left a comment
Member
There was a problem hiding this comment.
minor comments, mostly LGTM.
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
| }, | ||
| } | ||
|
|
||
| // Set the RequestInstanceUid flag on the tracked state to request the server for a new ID to use. |
Member
Author
There was a problem hiding this comment.
Thanks for the catch, removing it.
Signed-off-by: Paschalis Tsilias <[email protected]>
… concurrent Signed-off-by: Paschalis Tsilias <[email protected]>
tigrannajaryan
left a comment
Member
There was a problem hiding this comment.
Sorry for the delay, I was out last week.
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
tigrannajaryan
approved these changes
Aug 29, 2024
Comment on lines
+287
to
+298
| // Make sure that both Sync calls have gone through _before_ releasing the first one. | ||
| // This means that they're both called in parallel, and that the race | ||
| // detector would always report a race condition, but proper locking makes | ||
| // sure that's not the case. | ||
| assert.Eventually(t, func() bool { | ||
| return messages.Load() == 2 | ||
| }, 2*time.Second, 100*time.Millisecond, "both messages must have been processed successfully") | ||
|
|
||
| // Release the second Sync call so it can continue and wait for both of them to complete. | ||
| blockSyncCh <- struct{}{} | ||
| <-doneCh[0] | ||
| <-doneCh[1] |
Member
There was a problem hiding this comment.
I think this makes sense now. Thanks!
Member
|
Thanks for your patience @tpaschalis |
6 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR revives work done in previous PRs (#118, #120) to make sure that only a single package syncing operation is ever in flight and also adds a test.
The previous PRs did not account for needing to also protect
initStatusesandSetPackageStatuses, so that's why the Lock and Unlock statements are not just paired in doSync. If you think the intent would be clearer using a sync.WaitGroup, let me know.The new test makes sure that the mutex correctly protects the local storage; if we comment out the calls to Lock/Unlock and run the test with the
-raceflag we can see the race condition taking placeDetails
Fixes #84