Skip to content

fix(inkless:consume): handle error path in lastOffsetForLeaderEpoch#554

Merged
viktorsomogyi merged 1 commit intomainfrom
jeqo/fix-migration-config
Mar 30, 2026
Merged

fix(inkless:consume): handle error path in lastOffsetForLeaderEpoch#554
viktorsomogyi merged 1 commit intomainfrom
jeqo/fix-migration-config

Conversation

@jeqo
Copy link
Copy Markdown
Contributor

@jeqo jeqo commented Mar 27, 2026

for diskless topics

When FetchOffsetHandler returns an error from the control plane, timestampAndOffset is empty. Check for the error first and use UNDEFINED_EPOCH_OFFSET as fallback instead of calling Optional.get() on an empty value.

@jeqo jeqo force-pushed the jeqo/fix-migration-config branch from fcb9268 to c0e5887 Compare March 27, 2026 16:56
…or diskless topics

When FetchOffsetHandler returns an error from the control plane,
timestampAndOffset is empty. Check for the error first and use
UNDEFINED_EPOCH_OFFSET as fallback instead of calling Optional.get()
on an empty value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jeqo jeqo force-pushed the jeqo/fix-migration-config branch from c0e5887 to 1068083 Compare March 27, 2026 18:08
@jeqo jeqo marked this pull request as ready for review March 27, 2026 18:08
@jeqo jeqo requested a review from Copilot March 27, 2026 18:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes ReplicaManager.lastOffsetForLeaderEpoch for diskless topics when the control plane returns an error and the timestampAndOffset is empty, avoiding an Optional.get() crash and returning a defined fallback offset instead.

Changes:

  • Handle control-plane error results before reading timestampAndOffset, falling back to UNDEFINED_EPOCH_OFFSET.
  • Add a unit test covering the diskless control-plane error path.
  • Update imports to support the new logic and test.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/src/main/scala/kafka/server/ReplicaManager.scala Avoids Optional.get() on empty timestampAndOffset for diskless lastOffsetForLeaderEpoch, adds fallback handling and logging.
core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala Adds a regression test ensuring diskless lastOffsetForLeaderEpoch returns the correct error code and UNDEFINED_EPOCH_OFFSET when the control plane errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/main/scala/kafka/server/ReplicaManager.scala
@viktorsomogyi viktorsomogyi merged commit 82f8e36 into main Mar 30, 2026
13 checks passed
@viktorsomogyi viktorsomogyi deleted the jeqo/fix-migration-config branch March 30, 2026 14:38
jeqo added a commit that referenced this pull request Mar 30, 2026
…or diskless topics (#554)

When FetchOffsetHandler returns an error from the control plane,
timestampAndOffset is empty. Check for the error first and use
UNDEFINED_EPOCH_OFFSET as fallback instead of calling Optional.get()
on an empty value.
jeqo added a commit that referenced this pull request Mar 30, 2026
…or diskless topics (#554)

When FetchOffsetHandler returns an error from the control plane,
timestampAndOffset is empty. Check for the error first and use
UNDEFINED_EPOCH_OFFSET as fallback instead of calling Optional.get()
on an empty value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants