-
Notifications
You must be signed in to change notification settings - Fork 611
[server] Fix orphan segments after full truncation #4013
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1554,7 +1554,13 @@ private static void loadWritersFromRecords( | |
| Map<Long, WriterAppendInfo> loadedWriters = new HashMap<>(); | ||
| for (LogRecordBatch batch : records.batches()) { | ||
| if (batch.hasWriterId()) { | ||
| updateWriterAppendInfo(writerStateManager, batch, loadedWriters, false); | ||
| long writerId = batch.writerId(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we keep recovery on the existing |
||
| WriterAppendInfo appendInfo = | ||
| loadedWriters.computeIfAbsent( | ||
| writerId, id -> writerStateManager.prepareUpdate(id)); | ||
| // The records have already been accepted and persisted. Recovery rebuilds writer | ||
| // state without applying online client sequence validation. | ||
| appendInfo.appendForRecovery(batch); | ||
| } | ||
| } | ||
| loadedWriters.values().forEach(writerStateManager::update); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
newOffsetequals the segment's base offset, this deletes the old segment before its replacement is opened.deleteIfExists()closes the log channel, but the old object remains the active entry insegments; an unsynchronized read can therefore select a closed segment, and if deletion orLogSegment.open()fails thisLocalLoginstance is left pointing at an unusable active segment. Please rename the old files to the.deletedsuffix to free the original paths, install the replacement, and only then physically delete the old segment.