Repository navigation
Conversation
For managed-replica diskless partitions (RF > 1, tiered partitions at any RF, and switched partitions with a local classic prefix), `InklessTopicMetadataTransformer` previously selected the client-facing leader by hashing across candidate replicas. That hash came from the unmanaged RF=1 design, where no real replica assignment existed to balance load across brokers. With managed replicas, KRaft already places replicas across racks and balances leadership through preferred leader election. Hashing masked the controller leader from clients and tooling without an AZ, so preferred leader elections had no visible effect and leadership-skew checks saw the hash distribution instead of KRaft leadership. Pass `partition.leaderId()` into `selectLeaderForManagedReplicas` for both `Metadata` and `DescribeTopicPartitions` responses, and select it whenever it is in the candidate replica set (same-AZ replicas or cross-AZ alive eligible replicas). When the controller leader isn't a candidate (such as when it is in another AZ, offline, absent, or outside the ISR during a local-prefix switch), fall back to `selectByHash` for deterministic routing and cache locality. Non-replica fallbacks and the untiered RF=1 path stay unchanged. Assisted-by: Gemini 4 Neon
`DeleteRecordsAcrossTiersTest` previously ran with no `broker.rack` and no `diskless_az`, relying on hash-based leader selection to route clients to a follower. Because clients without an AZ now receive the controller leader, both the follower read guard test and `DeleteRecords` forwarding would land on the real KRaft leader and stop exercising the follower paths. Assign a distinct `broker.rack` to each broker in `DeleteRecordsAcrossTiersTest`, add optional `client_id` and `consumer_properties` hooks in `ConsolidationVerifier`, and pin `diskless_az` to a follower's rack for the follower read guard consumers (old and modern) and for cross-tier `DeleteRecords`. Update the test docstrings to match. Assisted-by: Gemini 4 Neon
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The documentation omits the same-AZ non-replica fallback for untiered managed replicas without a local-only classic prefix, incorrectly implying that cross-AZ controller-leader routing is considered first.
1 open issue
What changed in this PR
This PR aligns client-facing metadata for managed-replica diskless partitions with KRaft leadership while preserving availability-zone routing and deterministic hash fallbacks.
Changes:
- Prefer the controller-selected partition leader when it belongs to the eligible candidate set.
- Add leader-selection coverage and pin DeleteRecords system tests to follower racks.
- Update routing documentation and comments to describe the new preference.
| File | Description |
|---|---|
tests/kafkatest/tests/inkless/inkless_topic_switch_test.py |
Clarify the leader-lookup helper’s docstring. |
tests/kafkatest/tests/inkless/consolidation_delete_records_across_tiers_test.py |
Pin clients to follower racks to preserve follower-path coverage. |
tests/kafkatest/services/inkless/consolidation_verifier.py |
Add client configuration options for follower routing. |
storage/inkless/src/test/java/io/aiven/inkless/metadata/InklessTopicMetadataTransformerTest.java |
Cover leader preference, AZ locality, and fallback cases. |
storage/inkless/src/main/java/io/aiven/inkless/metadata/InklessTopicMetadataTransformer.java |
Prefer the controller-selected leader within candidate replicas. |
docs/inkless/DISKLESS_CONSOLIDATION.md |
Update routing and forwarding-authorization guidance. |
docs/inkless/CLIENT-BROKER-AZ-ALIGNMENT.md |
Describe leader preference and hash-based fallbacks. |
core/src/main/scala/kafka/server/DisklessDeleteRecordsForwarder.scala |
Update comments explaining when requests reach followers. |
Review effort: Balanced
…icas Update the AZ-alignment guide, consolidation guide, and `DisklessDeleteRecordsForwarder` comment to reflect that `InklessTopicMetadataTransformer` prefers the controller leader within the chosen replica set and routes to a follower only when an AZ-aware client stays on a same-AZ follower or the controller leader isn't an eligible candidate. Assisted-by: Gemini 4 Neon
jeqo
force-pushed
the
jeqo/metadata-response-controller-leader
branch
from
November 25, 2026 11:45
ef8b816 to
411dc0c
Compare
jeqo
marked this pull request as ready for review
November 25, 2026 12:31
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.

For managed-replica diskless partitions,
InklessTopicMetadataTransformerpreviously hashed over candidate replicas to pick the client-facing leader. Clients and tooling without an AZ saw the hash result instead of KRaft leadership, so preferred leader elections had no visible effect and leadership-skew checks reported the hash distribution.With managed replicas, KRaft already distributes replicas across racks and balances leadership through preferred leader election. Preferring the controller leader whenever it is in the candidate replica set aligns metadata responses with KRaft leadership while keeping deterministic hash fallback when the controller leader isn't an eligible candidate.
Commits
fe5638d4cafix(inkless:metadata): prefer controller leader for managed replicasdb32802697test(inkless:kafkatest): pin follower rack in DeleteRecords testsef8b816be5docs(inkless): document controller-leader preference for managed replicasSee the commit messages for the reasoning behind each step.
Operator impact
RF=1partitions keep hash-based selection.Test plan
InklessTopicMetadataTransformerTest: coversnullAZ forMetadataandDescribeTopicPartitions(tiered and diskless-only), fallback to hash when the controller leader is offline,-1, or outside the ISR during a local-prefix switch, cross-AZ fallback with an alive controller leader, and same-AZ selection with multiple replicas in the client AZ.DeleteRecordsAcrossTiersTest(consolidation_delete_records_across_tiers_test.py): pinsdiskless_azto a follower's rack via per-brokerbroker.rackoverrides so bothtest_delete_records_follower_read_guard(pre-KIP-392 and modern consumers) andDisklessDeleteRecordsForwarderintest_delete_records_across_tierskeep exercising the follower paths. Verified locally withducker-ak: both tests passed (2/2), withDisklessDeleteRecordsForwarderforwardingDELETE_RECORDSfrom the pinned follower to the leader and both consumer generations running against the pinned follower rack.