Commit 2db7148
[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 e14bb2e commit 2db7148
1 file changed
+8
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
771 | | - | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
772 | 776 | | |
773 | 777 | | |
774 | 778 | | |
775 | 779 | | |
776 | 780 | | |
777 | | - | |
778 | | - | |
779 | | - | |
| 781 | + | |
780 | 782 | | |
781 | 783 | | |
782 | 784 | | |
| |||
820 | 822 | | |
821 | 823 | | |
822 | 824 | | |
823 | | - | |
824 | | - | |
825 | | - | |
| 825 | + | |
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
| |||
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
| 852 | + | |
852 | 853 | | |
853 | 854 | | |
854 | 855 | | |
| |||
0 commit comments