forked from redpanda-data/redpanda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here’s a sequence of events that reproduces the issue: [start, end], where start == end-1 means the batch is empty [0, 0] [1, 0] [1, 0], [1, 1] [2, 2] Goal: truncate at 2), leave only 1] 1. find starting point to truncate by looking roughly for offset 1 (see `segment_index::find_nearest(model::offset)`) 2. get offset 0 as the seek starting point, we’ll seek forward from 0 until we see offset 2, and use the preceding batch 3. read from cache for [0, 0] [1, 0] (log_reader.read_some() last record is the first [1, 0] batch) (see `log_segment_batch_reader::read_some()`) 4. read from disk from where cache left off (see `log_segment_batch_reader::read_some()`), starting at the record following [1, 0]: 0 + 1 = 1 5. skip anything with last_offset < 1, so jump to [1, 1] (see `skipping_consumer::accept_batch_start()`) 6. we missed accumulating file size for the second [1, 0] batch (see `offset_to_filepos_consumer::operator()`) 7. because the returned file size is too low, we truncate at too low of a filepos (see `disk_log_impl::do_truncate()`) General problems: - when switching over from cache to disk reader (redpanda-data#4), we didn’t account for empty batches in the batch cache, causing us to skip portions of the file when figuring out where to truncate - even more generally, the interplay between offset_to_filepos_consumer and the skipping_consumer doesn’t expect empty batches at all, resulting in incorrect skipping when trying to figure out where to truncate
- Loading branch information
Showing
9 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters