Repository navigation
fix(inkless:switch): serve pending ListOffsets from the classic log and defer lookups past a stale high watermark [KC-756] [KC-763] - #873
Merged
Conversation
…nd defer lookups past a stale high watermark [KC-756] [KC-763] The router sent a pending partition of a consolidating topic to the control plane, which has no entry for the partition until the seal commits. The client got `UNKNOWN_TOPIC_OR_PARTITION`, and `kafka-topic-switch.sh state` failed on the partitions an operator needs it for. A pending partition now answers from the classic log on every topic. The leader and the in-sync followers answer client requests, because the metadata transformer sends clients to any alive ISR member while the switch is pending. A client timestamp lookup hides a match at or past the last fetchable offset. The router read that answer as a miss and returned the control-plane offset, so a consumer skipped the records between a stale high watermark and the start of the diskless log. The searchable range of a client lookup now ends at the last fetchable offset, so the existing guard answers `OFFSET_NOT_AVAILABLE` while that offset is before the diskless log. Assisted-by: Claude Fable 5.2
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the ListOffsets routing and timestamp-lookup changes.
No open issues 🎉
What changed in this PR
This PR fixes ListOffsets routing during classic-to-diskless switches and prevents timestamp lookups from skipping retained records when a replica’s high watermark is stale. It extends the lookup-gap protection introduced in #870.
Changes:
- Route pending-switch lookups to the classic log, allowing in-sync followers to answer client requests.
- Bound client timestamp searches by the high watermark or last stable offset, while replica requests retain the log end offset.
- Add regression tests and document pending-switch behavior and lookup deferrals.
| File | Description |
|---|---|
docs/inkless/DISKLESS_CONSOLIDATION.md |
Explain client search bounds and stale-watermark deferrals. |
docs/inkless/CLASSIC_TO_DISKLESS_SWITCH.md |
Document pending-switch routing and post-seal lookup errors. |
core/src/test/scala/unit/kafka/server/ReplicaManagerInklessTest.scala |
Add real-log tests for stale watermarks and pending-switch follower access. |
core/src/test/scala/unit/kafka/server/DisklessFetchOffsetRouterTest.scala |
Cover pending-switch routing and client-versus-replica access. |
core/src/main/scala/kafka/server/ReplicaManager.scala |
Apply isolation-aware search bounds and pass the broker ID to the router. |
core/src/main/scala/kafka/server/DisklessFetchOffsetRouter.scala |
Route pending switches through classic storage with ISR-aware follower access. |
Review effort: Balanced
viktorsomogyi
approved these changes
Nov 16, 2026
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.
This PR fixes two cases where
DisklessFetchOffsetRouterasks the control plane for offsets that the control plane can't answer correctly.Pending switch on a consolidating topic
A partition whose switch is pending (
classicToDisklessStartOffset = -2) took the classic-only path only if the topic didn't consolidate. The switch setsremote.storage.enable, and the topic reads as consolidating from that point. The pending partition then took the hybrid path:EARLIEST_TIMESTAMP,LATEST_TIMESTAMP, andMAX_TIMESTAMPwent to the control plane.UNKNOWN_TOPIC_OR_PARTITION.DelayedRemoteListOffsetsmaps that exception to the client response.kafka-topic-switch.sh statecallslistOffsetsfor the earliest and latest offsets of every partition, and failed on a pending partition.A pending partition now takes the classic-only path on every topic. For example, with a classic log that holds offsets 0 to 999,
LATESTreturns 1000 andEARLIESTreturns 0 while the switch is pending.The leader and the in-sync followers answer client requests.
InklessTopicMetadataTransformeradvertises any alive ISR member as the leader while the classic prefix lives only on local disks, which includes the pending state. A leader-only lookup would answerNOT_LEADER_OR_FOLLOWERto a client that the transformer sent to a follower. A replica outside the ISR, and every replica fetcher request, still gets the leader-only lookup. This rule also applies to a pending partition of a topic that doesn't consolidate, which was leader-only before.Stale high watermark on a hybrid partition
For a timestamp lookup, the router searches the local log first and asks the control plane on a miss. A client lookup hides a match at or past the last fetchable offset:
classicFetchOffsetanswersNONEwith offset-1. The router read that answer as a miss.For example, a consolidating replica restarts with high watermark 1100 and log end offset 1300, and the WAL is pruned up to 1200. A consumer asks for a timestamp whose first match is offset 1150. The local search hides the match, the control plane searches from 1200 and returns 1200, and the consumer skips offsets 1150 to 1199 without an error.
The guard from #870 compares the searchable end of the local log with the start of the diskless log. It used the log end offset (1300), which is past the diskless start (1200). For a client request,
classicSearchRangenow ends at the high watermark, or at the last stable offset forread_committed. In the example, 1100 is before 1200, and the lookup getsOFFSET_NOT_AVAILABLE(LEADER_NOT_AVAILABLEbefore version 5) until the high watermark moves past the WAL start. A replica request keeps the log end offset.The same bound covers a switched leader whose high watermark is below the seal: the existing seal check defers the lookup.
Not in this PR
After the controller commits the seal and until the leader initializes the control plane,
ListOffsetsfor the latest offset still fails withUNKNOWN_TOPIC_OR_PARTITION. On a consolidating topic, the earliest offset fails the same way. This PR doesn't fall back to the classic log there.PostgresControlPlanerunsListOffsetson the read connection, and a read replica that lags behind the primary reports a missing entry for a partition that already holds diskless records. A fallback would then return a stale offset instead of an error.No system test runs
kafka-topic-switch.sh stateon a pending partition.Testing
DisklessFetchOffsetRouterTestcovers a pending partition of a consolidating topic for the latest, earliest, max, and specific timestamps. It also covers a client request on an in-sync replica and a replica fetcher request on an in-sync replica.ReplicaManagerInklessTestcovers a pending partition of a consolidating topic on a real local log: the latest and earliest offsets on an in-sync follower, andNOT_LEADER_OR_FOLLOWERoutside the ISR. The control plane gets no call.ReplicaManagerInklessTestcovers a timestamp lookup on a replica with high watermark 700, log end offset 900, and WAL start 800. A client lookup getsOFFSET_NOT_AVAILABLEfor a hidden match and for a miss. A client lookup with high watermark 850 and a replica lookup get the control-plane offset.OFFSET_NOT_AVAILABLEfail.DisklessFetchOffsetRouterTestandReplicaManagerInklessTestpass.🤖 Generated with Claude Code
Assisted-by: Claude Fable 5.2