Skip to content

feat(inkless): Always allow fetching from replicas for migrated partitions - #593

Merged
gqmelo merged 2 commits into
mainfrom
giuseppelillo/follower-fetching-migrated-partitions
May 13, 2026
Merged

feat(inkless): Always allow fetching from replicas for migrated partitions#593
gqmelo merged 2 commits into
mainfrom
giuseppelillo/follower-fetching-migrated-partitions

Conversation

@giuseppelillo

@giuseppelillo giuseppelillo commented May 13, 2026

Copy link
Copy Markdown
Contributor

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
giuseppelillo force-pushed the giuseppelillo/follower-fetching-migrated-partitions branch from 44d0e67 to 306cc4c Compare May 13, 2026 09:25
…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
giuseppelillo force-pushed the giuseppelillo/follower-fetching-migrated-partitions branch from 306cc4c to ebd1c97 Compare May 13, 2026 09:53
@giuseppelillo giuseppelillo changed the title feat(inkless): Always allow fetching from followers for migrated partitions feat(inkless): Always allow fetching from replicas for migrated partitions May 13, 2026
@giuseppelillo
giuseppelillo marked this pull request as ready for review May 13, 2026 09:54
gqmelo
gqmelo previously approved these changes May 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.isMigratedPartitionFromClassicToDiskless and use it to override leader-only fetch enforcement for migrated partitions.
  • Extend Partition.fetchRecords with an allowReplica flag to bypass fetchOnlyLeader checks 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.

Comment thread core/src/main/scala/kafka/server/ReplicaManager.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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))

Comment thread core/src/main/scala/kafka/server/ReplicaManager.scala
Comment thread core/src/main/scala/kafka/cluster/Partition.scala
@gqmelo
gqmelo merged commit 568b949 into main May 13, 2026
10 checks passed
@gqmelo
gqmelo deleted the giuseppelillo/follower-fetching-migrated-partitions branch May 13, 2026 14:51
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.
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