-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sealed segment without IndexStart #31
Comments
@rledisez Thanks for reporting this and describing how to reproduce! Sorry I only just saw this, I will work on reproducing that issue in a test. Would you be able to share more context around what was happening in your cluster. Is this in Consul or another bit of software? Are you running in production or a testing environment. Thanks! |
@dhiaayachi and I looked at this and you've completely right - this is a case that fell through the cracks! In typical operation it's the Segment writer that decides when it's full and writes out the segment index - the WAL just writes to it until it does so and then updates the meta data with that index and creates a new segment. When I designed tail truncation, I decided it's simpler to just seal the tail segment if we still keep some records in it but not all and create a new one rather than try to reason about overwriting only the records we need (which may have been committed in a batch with records that are being truncated etc.) This is still sensible as it means we don't have to reason about this in the storage format and crash recovery. BUT I totally missed that just marking the segment as sealed in metadata isn't enough. The tests cover this common case, but use mocks at each layer which has many advantages but meant that this missed expectation between the WAL "sealing" a segment while the segment writer only actually writes out indexes when it's full is an issue. I propose to fix it with a |
Thx for the detailed feedback. To give a bit of context I'm working on a software using hashicorp/raft. This issue appeared when I was running a test that kills the leader. It was sometimes (I guess) killed right before the log was propagated to followers, so when it came back in the cluster, the new follower had a lesser index. |
Thanks @rledisez! I have a PR that should fix it up for review. |
In this trace, raft is clearing the last index from the WAL (424). It calls
(w *WAL) DeleteRange()
which calls(w *WAL) truncateTailLocked()
.truncateTailLocked()
seals the segment but does not set the IndexStart, which is wrong from my understanding. So at the next start, the segment is sealed without any IndexStart set, which triggers the panic from(r *Reader) findFrameOffset
.The text was updated successfully, but these errors were encountered: