feat(inkless): Always allow fetching from replicas for migrated partitions - #593
Merged
gqmelo merged 2 commits intoMay 13, 2026
Merged
Conversation
giuseppelillo
force-pushed
the
giuseppelillo/follower-fetching-migrated-partitions
branch
from
May 13, 2026 09:25
44d0e67 to
306cc4c
Compare
…tions Partitions migrated from classic to diskless are handled like full diskless partitions from the metadata point of view. This means that a replica can be advertised as a leader from the InklessTopicMetadataTransformer. Allow fetching from replicas for all types of fetch requests that want to read from a migrated partition so the unified log can be read also when a client request does not support follower fetching.
giuseppelillo
force-pushed
the
giuseppelillo/follower-fetching-migrated-partitions
branch
from
May 13, 2026 09:53
306cc4c to
ebd1c97
Compare
giuseppelillo
marked this pull request as ready for review
May 13, 2026 09:54
gqmelo
previously approved these changes
May 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the broker fetch path to relax the “leader-only” restriction when serving reads for classic→diskless migrated (“hybrid”) partitions, enabling older client fetch requests (which implicitly require leader fetches due to missing clientMetadata) to succeed even when they hit a non-leader replica.
Changes:
- Add
ReplicaManager.isMigratedPartitionFromClassicToDisklessand use it to override leader-only fetch enforcement for migrated partitions. - Extend
Partition.fetchRecordswith anallowReplicaflag to bypassfetchOnlyLeaderchecks when appropriate. - Add/adjust unit tests to validate the new migrated-partition detection and the older-client follower-read behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| core/src/main/scala/kafka/server/ReplicaManager.scala | Adds migrated-partition detection and relaxes leader-only fetch logic for migrated partitions. |
| core/src/main/scala/kafka/cluster/Partition.scala | Extends fetchRecords to support an explicit override (allowReplica) for leader-only enforcement. |
| core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala | Adds tests for older-client fetch behavior on hybrid partitions and for the migrated-partition predicate. |
| core/src/test/scala/unit/kafka/cluster/PartitionTest.scala | Updates mocking to match the new fetchRecords signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
core/src/main/scala/kafka/server/ReplicaManager.scala:2259
- The PR description says follower fetching should be allowed for “all types of fetch requests” that read from migrated partitions, but the implementation only relaxes leader-only for older consumer fetches (
params.isFromConsumer && params.clientMetadata.isEmpty) and explicitly excludes share and broker-to-broker follower fetches. If the narrower scope is intended, the PR description (and/or inline comment) should be updated to reflect that; otherwise the condition likely needs to be broadened.
// requirement so any in-sync replica can serve the classic portion of the read. This is
// scoped to older consumer fetches that don't supply clientMetadata (pre-KIP-392 / no
// rackId), which would otherwise get NOT_LEADER_OR_FOLLOWER on a non-leader broker.
// Broker-to-broker follower replication and share fetches are intentionally excluded.
// The check is ordered so that the metadata lookup is only performed when the override
// could actually apply.
val isOlderConsumer = params.isFromConsumer && params.clientMetadata.isEmpty
val allowReplica = !params.fetchOnlyLeader() ||
(isOlderConsumer && isMigratedPartitionFromClassicToDiskless(tp))
gqmelo
approved these changes
May 13, 2026
giuseppelillo
added a commit
that referenced
this pull request
May 15, 2026
…tions (#593) * feat(inkless): Always allow fetching from replicas for migrated partitions Partitions migrated from classic to diskless are handled like full diskless partitions from the metadata point of view. This means that a replica can be advertised as a leader from the InklessTopicMetadataTransformer. Allow fetching from replicas for all types of fetch requests that want to read from a migrated partition so the unified log can be read also when a client request does not support follower fetching.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partitions migrated from classic to diskless are handled like full diskless partitions from the metadata point of view. This means that a replica can be advertised as a leader from the
InklessTopicMetadataTransformer.Allow fetching from replicas for all types of fetch requests that want to read from a migrated partition so the unified log can be read also when a client request does not support follower fetching.