Commit 2ea01ff
[SharovBot] Fix data race between buildFiles and recalcVisibleFiles (#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>1 parent 9746330 commit 2ea01ff
1 file changed
+8
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
781 | | - | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
782 | 786 | | |
783 | 787 | | |
784 | 788 | | |
785 | 789 | | |
786 | 790 | | |
787 | | - | |
788 | | - | |
789 | | - | |
| 791 | + | |
790 | 792 | | |
791 | 793 | | |
792 | 794 | | |
| |||
830 | 832 | | |
831 | 833 | | |
832 | 834 | | |
833 | | - | |
834 | | - | |
835 | | - | |
| 835 | + | |
836 | 836 | | |
837 | 837 | | |
838 | 838 | | |
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
| 862 | + | |
862 | 863 | | |
863 | 864 | | |
864 | 865 | | |
| |||
0 commit comments