network: fix peerstore Get/Put races#6261
Merged
algorandskiy merged 6 commits intoalgorand:masterfrom Mar 3, 2025
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6261 +/- ##
==========================================
- Coverage 51.80% 50.18% -1.62%
==========================================
Files 644 644
Lines 86643 86644 +1
==========================================
- Hits 44886 43484 -1402
- Misses 38887 40219 +1332
- Partials 2870 2941 +71 ☔ View full report in Codecov by Sentry. |
gmalouf
previously approved these changes
Feb 24, 2025
cce
reviewed
Feb 25, 2025
jannotti
reviewed
Feb 27, 2025
jannotti
approved these changes
Feb 28, 2025
cce
approved these changes
Mar 3, 2025
Contributor
cce
left a comment
There was a problem hiding this comment.
OK, big lock is easier for reader to understand, LGTM!
This was referenced May 15, 2025
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.
Summary
Fix for a race condition seen in this test run
peerstore's
GetConnectionWaitTimegets a peerstore entry, calculates number ofrecentConnectionTimesto remove and then callspopNElementsthat also gets the same entry from peerstore and attempts to remove number of entries calculated on the first copy.Fixed by removing the
addressDatamutex and adding it toPeerStoreitself. Otherwise all thesePeerStoremethods are racy.Test Plan
Existing tests