You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "haung921209 (via GitHub)" <gi...@apache.org> on 2026/08/20 05:50:04 UTC

[PR] KAFKA-20961: Carry leader epoch history over when replacing the current log with the future log [kafka]

haung921209 opened a new pull request, #23205:
URL: https://github.com/apache/kafka/pull/23205

   Moving a partition between log directories replaces the current log with the
   future log, but the future log's leader epoch cache is only ever populated from
   the record batches copied into it. Epochs with no records behind them - such as
   the one Partition#makeLeader assigns on every leader election - therefore exist
   only in the current log's cache and are dropped by the swap.
   
   A leader whose cache no longer holds the epoch a follower reports as its last
   fetched epoch cannot determine that epoch's end offset, so it answers the fetch
   with OffsetOutOfRangeException. The follower then resets its fetch offset to the
   higher of its own log end offset and the leader's log start offset, which on an
   idle partition is the offset it already had, so nothing is truncated and its next
   fetch is identical. The two loop until records are appended to the partition.
   
   This PR copies the epoch history from the log being replaced. This is sound
   because the swap only happens once the future log has caught up, so both logs
   hold the same offsets. The parameter guarding the high watermark transfer is
   renamed to say why the inheritance is valid.
   
   This appears to be the same defect as KAFKA-15608 (analysis posted on both
   tickets). It differs from the earlier attempt in #14553 in two ways: the full
   epoch history is carried over rather than only the latest entry (dropping
   intermediate record-less epochs would still leave the follower subject to
   spurious diverging-epoch truncation), and the transfer is confined to the
   caught-up swap path - recoverAbandonedFutureLogs offers no LEO-equality
   guarantee, so inheriting there could fabricate epoch entries beyond the log end.
   
   ### Testing
   
   - New Partition test reproduces the reported symptom deterministically on
     trunk: after moving an idle partition to another log directory, a follower
     fetch with its last fetched epoch fails with
     `OffsetOutOfRangeException: Could not determine the end offset of the last
     fetched epoch Optional[5]` before this change and is served after it.
   - New LogManager test pins the full-history transfer (three epoch entries).
   - Targeted suites green: PartitionTest, ReplicaManagerTest, UnifiedLogTest,
     LogManagerTest, LeaderEpochFileCacheTest, ReplicaAlterLogDirsThreadTest,
     LeaderEpochIntegrationTest, OffsetsForLeaderEpochTest (526 tests, 0 failures).
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20961: Carry leader epoch history over when replacing the current log with the future log [kafka]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23205:
URL: https://github.com/apache/kafka/pull/23205#issuecomment-5448949186

   A label of 'needs-attention' was automatically added to this PR in order to raise the
   attention of the committers. Once this issue has been triaged, the `triage` label
   should be removed to prevent this automation from happening again.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20961: Carry leader epoch history over when replacing the current log with the future log [kafka]

Posted by "dadufour (via GitHub) via jira" <ji...@kafka.apache.org>.
dadufour commented on PR #23205:
URL: https://github.com/apache/kafka/pull/23205#issuecomment-6909521389

   Hello,
   what is the status on this issue? Is there any plan to integrate the fix?


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20961: Carry leader epoch history over when replacing the current log with the future log [kafka]

Posted by "github-actions[bot] (via GitHub) via jira" <ji...@kafka.apache.org>.
github-actions[bot] commented on PR #23205:
URL: https://github.com/apache/kafka/pull/23205#issuecomment-6998608105

   A label of 'needs-attention' was automatically added to this PR in order to raise the
   attention of the committers. Once this issue has been triaged, the `triage` label
   should be removed to prevent this automation from happening again.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20961: Carry leader epoch history over when replacing the current log with the future log [kafka]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23205:
URL: https://github.com/apache/kafka/pull/23205#issuecomment-5612143390

   A label of 'needs-attention' was automatically added to this PR in order to raise the
   attention of the committers. Once this issue has been triaged, the `triage` label
   should be removed to prevent this automation from happening again.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20961: Carry leader epoch history over when replacing the current log with the future log [kafka]

Posted by "haung921209 (via GitHub)" <gi...@apache.org>.
haung921209 commented on PR #23205:
URL: https://github.com/apache/kafka/pull/23205#issuecomment-5579371503

   @hudeqi @mimaison could one of you take a look when you have a chance?
   
   This is the same defect as KAFKA-15608 (#14553 was the earlier attempt): when `LogManager` replaces the current log with the future log, the leader epoch cache is not carried over, so an epoch with no records behind it is lost and the leader ends up throwing `OffsetOutOfRangeException` in a loop on an idle partition. What's different from #14553 is a deterministic unit-level reproduction on trunk (three tests that fail before the fix) and carrying the full epoch history rather than only the latest entry.
   
   I don't have Jira permissions yet to assign KAFKA-20961 to myself — if someone could add me to the contributors list I'd appreciate it.
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20961: Carry leader epoch history over when replacing the current log with the future log [kafka]

Posted by "haung921209 (via GitHub) via jira" <ji...@kafka.apache.org>.
haung921209 commented on PR #23205:
URL: https://github.com/apache/kafka/pull/23205#issuecomment-6965890373

   @dadufour  Thanks for checking in. The fix is ready and still merges cleanly on trunk, but it hasn't had a committer review yet.
   
   @hudeqi @mimaison gentle ping: since another user is now hitting this (KAFKA-20961 / KAFKA-15608), would one of you have time for a review? Happy to rebase or split the change if that makes it easier.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org