[Testing] Fix data race in cluster-prefix RecordCache - #8627
Open
janezpodhostnik wants to merge 1 commit into
Open
[Testing] Fix data race in cluster-prefix RecordCache#8627janezpodhostnik wants to merge 1 commit into
janezpodhostnik wants to merge 1 commit into
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
janezpodhostnik
force-pushed
the
janez/flaky-test-followup-coverage
branch
from
July 29, 2026 14:42
8aac74a to
1f7def0
Compare
zhangchiqing
approved these changes
Jul 30, 2026
Kay-Zee
approved these changes
Jul 31, 2026
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.
Follow-up to #8626, which fixed flaky tests by (among other things) weakening some
assertions. This PR restores that coverage — and fixes a production data race the new
coverage immediately exposed.
Data race fix in
RecordCache(production code)network/p2p/inspector/internal/cache/cache.go:ReceivedClusterPrefixedMessageandGetWithInitread.Gaugefrom the record pointer returned byAdjustWithInitafterthe backend lock is released. Records are mutated in place, so this read races with
concurrent adjustments of the same record. The inspector runs 5 inspection workers by
default, so this race is live on production nodes; #8626 pinning the cluster-prefix test
to a single worker had hidden it from the test suite.
Fix: capture the gauge inside the locked adjust closure instead of dereferencing the
returned pointer.
New/extended tests
network/p2p/inspector/validation: new multi-worker companion subtest ofTestNewControlMsgValidationInspector_validateClusterPrefixedTopic— with the defaultworker count, between 1 and one-per-message notifications may be disseminated past the
hard threshold (the tracker increment and threshold check are not atomic). This is the
test that surfaced the race above.
consensus/hotstuff/votecollector: newTestRegisterVoteConsumer_CachingToVerifyingTransition— a vote consumer keepsreceiving votes, in arrival order, across the caching→verifying transition.
network/p2p/builder: negative-value cases inTestApplyResourceLimitOverrideand newTestBuildLibp2pResourceManagerLimits_NonPositiveOverridesKeepDefaults— non-positiveoverrides keep the scaled defaults and are never passed through to rcmgr, where negative
values carry special meaning (-1 unlimited, -2 block-all).
All touched packages pass
go test -racelocally (repeated runs).Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.