[SharovBot] Fix data race between buildFiles and recalcVisibleFiles#19590
Merged
Giulio2002 merged 2 commits intomainfrom Mar 4, 2026
Merged
[SharovBot] Fix data race between buildFiles and recalcVisibleFiles#19590Giulio2002 merged 2 commits intomainfrom
Giulio2002 merged 2 commits intomainfrom
Conversation
buildFiles() calls BeginFilesRo() on Domain and InvertedIndex without holding visibleFilesLock, racing with recalcVisibleFiles() which writes _visible/_visibleFiles under the same lock. Wrap the BeginFilesRo() calls in buildFiles() with visibleFilesLock.RLock() to synchronize with the writer, matching the pattern already used in Aggregator.BeginFilesRo(). Fixes TestHistoryVerification_WithUserTransactions DATA RACE. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
AskAlexSharov
requested changes
Mar 3, 2026
AskAlexSharov
approved these changes
Mar 4, 2026
sudeepdino008
pushed a commit
that referenced
this pull request
Mar 4, 2026
…19590) **[SharovBot]** Fix DATA RACE in `db/state/aggregator.go` ## Summary - `buildFiles()` calls `BeginFilesRo()` on `Domain` and `InvertedIndex` without holding `visibleFilesLock`, racing with `recalcVisibleFiles()` which writes `_visible`/`_visibleFiles` fields under the same lock - Wraps the `BeginFilesRo()` calls in `buildFiles()` with `a.visibleFilesLock.RLock()`/`RUnlock()` to synchronize with the writer, matching the pattern already used in `Aggregator.BeginFilesRo()` ## Test plan - [x] `go build ./...` passes - [x] `go test -race ./execution/verify/... -run TestHistoryVerification_WithUserTransactions` passes 3 consecutive times with no DATA RACE - [x] `go test -race ./db/state/...` passes with no DATA RACE 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
sudeepdino008
pushed a commit
that referenced
this pull request
Mar 4, 2026
…19590) **[SharovBot]** Fix DATA RACE in `db/state/aggregator.go` ## Summary - `buildFiles()` calls `BeginFilesRo()` on `Domain` and `InvertedIndex` without holding `visibleFilesLock`, racing with `recalcVisibleFiles()` which writes `_visible`/`_visibleFiles` fields under the same lock - Wraps the `BeginFilesRo()` calls in `buildFiles()` with `a.visibleFilesLock.RLock()`/`RUnlock()` to synchronize with the writer, matching the pattern already used in `Aggregator.BeginFilesRo()` ## Test plan - [x] `go build ./...` passes - [x] `go test -race ./execution/verify/... -run TestHistoryVerification_WithUserTransactions` passes 3 consecutive times with no DATA RACE - [x] `go test -race ./db/state/...` passes with no DATA RACE 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.
[SharovBot] Fix DATA RACE in
db/state/aggregator.goSummary
buildFiles()callsBeginFilesRo()onDomainandInvertedIndexwithout holdingvisibleFilesLock, racing withrecalcVisibleFiles()which writes_visible/_visibleFilesfields under the same lockBeginFilesRo()calls inbuildFiles()witha.visibleFilesLock.RLock()/RUnlock()to synchronize with the writer, matching the pattern already used inAggregator.BeginFilesRo()Test plan
go build ./...passesgo test -race ./execution/verify/... -run TestHistoryVerification_WithUserTransactionspasses 3 consecutive times with no DATA RACEgo test -race ./db/state/...passes with no DATA RACE🤖 Generated with Claude Code