-
Notifications
You must be signed in to change notification settings - Fork 206
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
[server/kv] Fix out of order exception after delete a not exist row #238
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 |
---|---|---|
|
@@ -619,14 +619,18 @@ private LogAppendInfo append(MemoryLogRecords records, boolean needAssignOffsetA | |
appendInfo.setMaxTimestamp(duplicatedBatch.timestamp); | ||
appendInfo.setStartOffsetOfMaxTimestamp(startOffset); | ||
} else { | ||
// Append the records, and increment the local log end offset immediately after | ||
// append because write to the transaction index below may fail, and we want to | ||
// ensure that the offsets of future appends still grow monotonically. | ||
localLog.append( | ||
appendInfo.lastOffset(), | ||
appendInfo.maxTimestamp(), | ||
appendInfo.startOffsetOfMaxTimestamp(), | ||
validRecords); | ||
// if there are records to append | ||
if (appendInfo.lastOffset() >= appendInfo.firstOffset()) { | ||
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. Skipping writing log has problem, because writer state of replicas is out-of-sync with leader. Besides, this if condition doesn't take effect, because, this method returned at the beginning as 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. Haven't noticed that the replica's writer state will be out-of-sync... |
||
// Append the records, and increment the local log end offset immediately after | ||
// append because write to the transaction index below may fail, and we want to | ||
// ensure that the offsets of future appends still grow monotonically. | ||
localLog.append( | ||
appendInfo.lastOffset(), | ||
appendInfo.maxTimestamp(), | ||
appendInfo.startOffsetOfMaxTimestamp(), | ||
validRecords); | ||
} | ||
|
||
updateHighWatermarkWithLogEndOffset(); | ||
|
||
// update the writer state. | ||
|
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.
cc @swuferhong , do you remember what cases to fix when we introduced this?
Besides, could you help to review this PR? How kafka client/server handle the sequence id if the produce messages are empty.
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.
It's used to fix the exception
LogSegmentOffsetOverflowException
when append empty log in methodLogSegment#ensureOffsetInRange
since thelargestOffset
will be 0. So I skip to append empty record to avoid that but it will cause replica's writer state out-of-sync.Let's to see how Kafka solve this....