hanahmily opened a new pull request, #1064: URL: https://github.com/apache/skywalking-banyandb/pull/1064
### Fix handoff controller TOCTOU race and sidx timestamp corruption during replay - [x] Add a unit test to verify that the fix works. - [x] Explain briefly why the bug exists and how to fix it. **Bug 1: TOCTOU race in size limit enforcement** The `canEnqueue` method used a read lock to check the size, then `updateTotalSize` used a separate write lock to increment it. Under concurrent enqueues, multiple goroutines could pass the check before any of them updated the total, allowing the disk size limit to be exceeded — filling up the disk. **Fix:** Replace `canEnqueue` with `tryReserveSize` which atomically checks and increments under a single write lock. Size is reserved upfront and rolled back on failure paths. **Bug 2: Missing sidx timestamps in handoff replay** When a data node recovers and queued parts are replayed, `readPartFromHandoff` only read `metadata.json` for core parts. Sidx parts (which use `manifest.json`) had `MinTimestamp`/`MaxTimestamp` left as zero. This caused corrupt segment creation on the recovered node — the same class of bug fixed in b8e1f72d for streaming sync. **Fix:** Read `manifest.json` for sidx parts with the same fallback chain as streaming sync: `MinTimestamp` pointer → `SegmentID` legacy → warn. Metadata read/parse errors are now explicit returns instead of silent warnings. **Bug 3: Orphaned parts in tsTable initialization** Parts not referenced by any snapshot were left on disk during initialization, wasting space. **Fix:** Delete orphaned parts when no snapshot references them during tsTable initialization for measure, stream, and trace. - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-banyandb/blob/main/CHANGES.md). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
