Commit fab1af6
authored
fix(bbr): add read lock to GetBaseModel to prevent concurrent map crash (#2570)
- `GetBaseModel()` reads `loraAdapterToBaseModel` and `baseModels` maps without
holding a lock, while `ConfigMapUpdateOrAddIfNotExist()` and `ConfigMapDelete()`
write to these maps under `ds.lock.Lock()`. In Go, concurrent map read and write
causes `fatal error: concurrent map read and map write`, which crashes the
process and cannot be recovered.
- Add `ds.lock.RLock()`/`RUnlock()` to `GetBaseModel()` to ensure safe concurrent
access.
- Add a concurrent read/write test to prevent regression.
- go test -race ./pkg/bbr/datastore/... test passed.1 parent 4d97138 commit fab1af6
2 files changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
194 | 209 | | |
195 | 210 | | |
196 | 211 | | |
| |||
0 commit comments