hachikuji opened a new pull request, #12963: URL: https://github.com/apache/kafka/pull/12963
The ID we use for snapshots consists of the exclusive committed offset and epoch. That is, the offset in the ID is one more than the offset of the last committed record. This is currently handled a bit inconsistently in the codebase. For example, `MetadataImage` internally tracks the inclusive highest offset and epoch of records contained within the image. However, for an empty image, which contains no log records, the offset is incorrectly initialized to 0. In this patch, I've tried to make the bookkeeping a little more consistent: - Use the exclusive offset/epoch in `MetadataImage` as an "imageId" (which then corresponds exactly to a the snapshotId generated from the image) - Also use the exclusive highest offset in `MetadataDelta` - Modify `RaftClient.createSnapshot` to pass the snapshotId directly instead of the inclusive last committed offset and epochs. The nice thing about this is that we can define a non-negative offset/epoch to represent each image. For an empty metadata image, we can use 0 as both the offset and epoch. Unfortunately, there are still a few places in the codebase which expect inclusive offsets, so we still have some awkward increments/decrements here and there. ### Committer Checklist (excluded from commit message) - [ ] Verify design and implementation - [ ] Verify test coverage and CI build status - [ ] Verify documentation (including upgrade notes) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
