mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-16 12:48:20 -04:00
798852e466
The commitlog creates new segments atomically, returning EEXIST if the segment already exists. This is to break a retry loop in case the filesystem becomes unwritable. This error did not contain any context about what does not exist, so this patch adds some. Also, an unhandled edge case has been discovered: When opening an existing log, the commitlog will try to resume the last segment for writing. If it finds a corrupt commit in that segment, it won't resume, but instead create a new segment at the corrupt commit's offset + 1. However, if the first commit in the last segment is corrupted, the offset will be that of the last segment -- trying to start a new segment will thus fail with EEXIST. Without additional recovery mechanisms, it is not obvious what to do in this case: the segment could contain valid data after the initial commit, so we certainly don't want to throw it away. Instead, we now detect this case and return `InvalidData` with some context. # Expected complexity level and risk 1 # Testing - [ ] A (regression) test is included
⚠️ Internal Crate ⚠️
This crate is intended for internal use only. It is not stable and may change without notice.