kafka/core
Steve Rodrigues 9d447be1ef
[KAFKA-9826] Handle an unaligned first dirty offset during log cleaning. (#8469) (#8543)
In KAFKA-9826, a log whose first dirty offset was past the start of the active segment and past the last cleaned point resulted in an endless cycle of picking the segment to clean and discarding it. Though this didn't interfere with cleaning other log segments, it kept the log cleaner thread continuously busy (potentially wasting CPU and impacting other running threads) and filled the logs with lots of extraneous messages.

This was determined to be because the active segment was getting mistakenly picked for cleaning, and because the logSegments code handles (start == end) cases only for (start, end) on a segment boundary: the intent is to return a null list, but if they're not on a segment boundary, the routine returns that segment.

This fix has two parts:

It changes logSegments to handle start==end by returning an empty List always.

It changes the definition of calculateCleanableBytes to not consider anything past the UncleanableOffset; previously, it would potentially shift the UncleanableOffset to match the firstDirtyOffset even if the firstDirtyOffset was past the firstUncleanableOffset. This has no real effect now in the context of the fix for (1) but it makes the code read more like the model that the code is attempting to follow.

These changes require modifications to a few test cases that handled this particular test case; they were introduced in the context of KAFKA-8764. Those situations are now handled elsewhere in code, but the tests themselves allowed a DirtyOffset in the active segment, and expected an active segment to be selected for cleaning.

Reviewer: Jun Rao <junrao@gmail.com>
2020-04-29 11:10:12 -07:00
..
src [KAFKA-9826] Handle an unaligned first dirty offset during log cleaning. (#8469) (#8543) 2020-04-29 11:10:12 -07:00
.gitignore