Files
seaweedFS/weed/storage
Chris Lu ba74185700 fix: CompactMap race condition causing runtime panic (#8029)
Fixed critical race condition in CompactMap where Set(), Delete(), and
Get() methods had issues with concurrent map access.

Root cause: segmentForKey() can create new map segments, which modifies
the cm.segments map. Calling this under a read lock caused concurrent
map write panics when multiple goroutines accessed the map simultaneously
(e.g., during VolumeNeedleStatus gRPC calls).

Changes:
- Set() method: Changed RLock/RUnlock to Lock/Unlock
- Delete() method: Changed RLock/RUnlock to Lock/Unlock, optimized to
  avoid creating empty segments when key doesn't exist
- Get() method: Removed segmentForKey() call to avoid race condition,
  now checks segment existence directly and returns early if segment
  doesn't exist (optimization: avoids unnecessary segment creation)

This fix resolves the runtime/maps.fatal panic that occurred under
concurrent load.

Tested with race detector: go test -v -race ./weed/storage/needle_map/...
2026-01-14 14:12:49 -08:00
..
2025-06-16 22:25:22 -07:00
2026-01-01 19:20:59 -08:00
2026-01-01 19:20:59 -08:00
2023-03-08 01:48:28 -08:00
2022-11-14 00:19:27 -08:00
2025-06-30 13:57:28 -07:00
2025-06-30 10:11:30 -07:00
2019-04-17 22:04:49 -07:00
2025-06-16 22:05:06 -07:00
2025-11-10 20:30:21 -08:00
2025-06-16 22:25:22 -07:00