Repository navigation
fix: handle corrupt WAL files during replay without panic - #26556
Conversation
Add bounds checking to prevent panic when WAL files are empty or truncated. Introduces `--wal-replay-fail-on-error` flag to control behavior when encountering corrupt WAL files during replay. - Add WalFileTooSmall error for files missing required header bytes - Validate minimum file size (12 bytes) before attempting deserialization - Make WAL replay configurable: skip corrupt files by default or fail on error - Add comprehensive tests for empty, truncated, and header-only files Closes #26549
a5a3732 to
4cc9c67
Compare
praveen-influx
left a comment
There was a problem hiding this comment.
Skipping corrupt WAL files looks like the right thing to do 💯 , it's nice to have an opt-out behavior as well ✅
I wonder how we ended up with the zero length files / partial writes - I was under the assumption we can never see partial writes on object store. If this can happen for WAL files, could this also happen on data (.parquet) files, catalog log files etc. WAL files are probably most frequently written files so the other ones are much less likely to run into this problem. It'd be good to understand whether it's possible to end up in similar situation for other files and address it in a separate issue.
From the reported issue my guess is they were using the file system backed object store, which doesn't have the same guarantees as a real object store. So it's possible to get the file created without data actually going into it. |
Summary
This PR fixes a critical issue where InfluxDB3 would panic on startup when encountering corrupt or empty WAL files, typically after power outages or disk failures.
Issue
When WAL files become corrupted (e.g., truncated to 0 bytes during power loss), the server would panic with:
This prevented the server from starting, requiring manual intervention to remove corrupt files.
Now, the user will see a WARN log when encountering corrupt WAL files:
The user can opt-out of this behaviour by specifying the
--wal-replay-fail-on-errorCLI argument.Solution
Added bounds checking in WAL deserialization:
WalFileTooSmallerror variant that clearly indicates expected vs actual file sizeMade WAL replay behavior configurable:
--wal-replay-fail-on-error(env:INFLUXDB3_WAL_REPLAY_FAIL_ON_ERROR)Enhanced error handling in WAL replay:
Test plan
Closes #26549