This function does not check that an entry in the index is also valid in the segment and thus can return values that are not valid. For normal operation this is fine as the index is always written to after the segment. However if there is an unclean node shutdown where the page cache is lost it is/appears possible that the index will contain data not also present in the segment (due to data re-ordering at the storage layer or file system).
Reproduction steps
Truncating some data from the segment file then running the function should be sufficient to show it returning offsets not present in the segment.
Describe the bug
This function does not check that an entry in the index is also valid in the segment and thus can return values that are not valid. For normal operation this is fine as the index is always written to after the segment. However if there is an unclean node shutdown where the page cache is lost it is/appears possible that the index will contain data not also present in the segment (due to data re-ordering at the storage layer or file system).
Reproduction steps
Expected behavior
It should include only valid epoch offsets.
Additional context
No response