Commit 9a00f9a
[SharovBot] Fix data race on bheapCache in db/rawdb (#19606)
**[SharovBot]**
## Summary
- Fix DATA RACE between `TestBlockStorage` and `TestBadBlocks` in
`db/rawdb`
- Add `sync.RWMutex` to protect concurrent access to the package-level
`bheapCache` variable
- The variable was being read in `TruncateCanonicalHash` and written in
`ResetBadBlockCache` without synchronization
## Test plan
- [x] `go test -race ./db/rawdb/... -run
"TestBlockStorage|TestBadBlocks" -count=3` passes with no DATA RACE
- [x] `go build ./...` passes
- [x] No test files modified
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent b8a1590 commit 9a00f9a
1 file changed
+19
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
| 109 | + | |
99 | 110 | | |
| 111 | + | |
| 112 | + | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
| |||
107 | 120 | | |
108 | 121 | | |
109 | 122 | | |
| 123 | + | |
110 | 124 | | |
| 125 | + | |
111 | 126 | | |
112 | 127 | | |
| 128 | + | |
113 | 129 | | |
| 130 | + | |
114 | 131 | | |
115 | 132 | | |
116 | 133 | | |
| |||
0 commit comments