Repository navigation
fix(inkless:switch): refuse reads of records that DeleteRecords removed in phase 1 [KC-867] - #902
Closed
giuseppelillo wants to merge 1 commit into
Closed
giuseppelillo wants to merge 1 commit into
giuseppelillo wants to merge 1 commit into
Conversation
…ed in phase 1 [KC-867]
In phase 1 of the switch, `DeleteRecords` below the seal advances the
log start of the leader and the cross-tier earliest offset in the control
plane, and returns success. The followers left the classic fetcher at the
seal, so they don't learn the new log start. The metadata routing sends
consumers to them, and they keep serving the deleted records until
phase 2.
On a 3-broker cluster, after `DeleteRecords` with offset 10 on a
partition sealed at 20, the leader had log start 10, both followers had
log start 0, and consumers in the zones of the followers read offset 0.
The change has three parts:
- Every replica refuses a consumer read below the seal of a phase 1
partition with `OFFSET_OUT_OF_RANGE` if the offset is below the
cross-tier earliest offset. `DisklessPhaseOneCrossTierEarliest` keeps
that offset in memory. A scheduled task reads it from the control plane
once per `cross.tier.log.start.report.interval.ms`, in one call for
every phase 1 partition on the broker. The fetch path reads only the
value in memory, so a slow control plane doesn't delay a request
handler thread. After a failed read the broker keeps the last value,
and with no value it serves the read.
- The leader holds the `DeleteRecords` response of a phase 1 partition
for two of those intervals, so that the other replicas have the new
value when the request succeeds. If the request timeout is shorter, the
leader answers `REQUEST_TIMED_OUT` at the timeout and keeps the records
deleted, as `DelayedDeleteRecords` does.
- If the control plane doesn't advance the cross-tier earliest offset of
a phase 1 partition, the leader answers `KAFKA_STORAGE_ERROR`, which the
client retries. It answered success before, and the followers then
served the deleted records with nothing to correct them.
Phase 2 and born-diskless partitions don't change.
## Testing
- `ReplicaManagerInklessTest` covers the read check on a follower and on
the leader, that the fetch path doesn't query the control plane, a
failed refresh, the hold, the request timeout, and a cross-tier earliest
offset that doesn't advance. The class passes with 321 tests.
- `InklessTopicTypeSwitcherClusterTest` has three new tests on 3 brokers:
- `testDeleteRecordsInPhaseOneHidesDeletedRecordsOnEveryReplica`:
consumers in every zone read from the new log start, also after
leadership moves to a follower.
- `testPhaseOnePrefixReadsDontWaitForAnUnreachableControlPlane`: with
the control-plane database paused, 12 consumers read the whole prefix
and a produce to a classic topic on the same broker isn't delayed.
- `testDeleteRecordsInPhaseOneFailsWhileTheControlPlaneIsUnreachable`:
the request fails while the database is paused, and a retry succeeds
afterward.
The class passes with 12 tests. With the production code of `main`,
the first and the third test fail.
- `:core:checkstyleMain`, `:core:checkstyleTest`, and
`:core:spotbugsMain` pass.
Assisted-by: Claude Opus 5.5
Assisted-by: Claude Fable 5.2
Contributor
Author
|
Replaced by #903, which rejects |
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.
In phase 1 of the classic-to-diskless switch,
DeleteRecordsbelow the seal returns success, but the followers keep serving the deleted records to consumers. With this change every replica refuses those reads when the request succeeds.Problem
DeleteRecordsbelow the seal advances the log start of the leader and the cross-tier earliest offset in the control plane, and returns at once. A follower learns the log start from fetch responses, and in phase 1 that path is closed:ReplicaManager.fetchMessagesanswers withlogStartOffset = 0, so the follower keeps its classic records.In phase 1 the metadata routing sends clients to any alive ISR member. A follower serves a read below the seal from its local log and checks only its own log start.
If the control plane doesn't advance the cross-tier earliest offset,
advanceCrossTierEarliestForDeleteRecordslogs the failure and the request still returns success. In phase 1 nothing corrects that later.Example before this change
On a 3-broker cluster, a topic with 3 replicas is sealed at offset 20 and stays in phase 1:
Admin.deleteRecords(beforeOffset(10))returns low watermark 10.logStartOffset=10, and both followers havelogStartOffset=0.Fix
The change has three parts:
OFFSET_OUT_OF_RANGEif the offset is below the cross-tier earliest offset. The newDisklessPhaseOneCrossTierEarliestkeeps that offset in memory. A scheduled task reads it from the control plane once percross.tier.log.start.report.interval.ms(1 second by default), in one call for every phase 1 partition on the broker. The fetch path reads only the value in memory, so a slow control plane doesn't delay a request handler thread. After a failed read the broker keeps the last value, and with no value it serves the read.DeleteRecordsresponse of a phase 1 partition for two of those intervals, so that the other replicas have the new value when the request succeeds. If the request timeout is shorter, the leader answersREQUEST_TIMED_OUTat the timeout and keeps the records deleted, asDelayedDeleteRecordsdoes.KAFKA_STORAGE_ERROR, which the client retries.Phase 2 and born-diskless partitions don't change.
Limits
DeleteRecordson a phase 1 partition takes two intervals, 2 seconds by default.Test plan
ReplicaManagerInklessTestcovers the read check on a follower and on the leader, that the fetch path doesn't query the control plane, a failed refresh, the hold, the request timeout, and a cross-tier earliest offset that doesn't advance. The class passes with 321 tests.InklessTopicTypeSwitcherClusterTesthas three new tests on 3 brokers:testDeleteRecordsInPhaseOneHidesDeletedRecordsOnEveryReplica: consumers in every zone read from the new log start, also after leadership moves to a follower.testPhaseOnePrefixReadsDontWaitForAnUnreachableControlPlane: with the control-plane database paused, 12 consumers read the whole prefix, and a produce to a classic topic on the same broker isn't delayed.testDeleteRecordsInPhaseOneFailsWhileTheControlPlaneIsUnreachable: the request fails while the database is paused, and a retry succeeds afterward.main, the first and the third new test fail.:core:checkstyleMain,:core:checkstyleTest, and:core:spotbugsMainpass.make valereports no alerts on the added lines.🤖 Generated with Claude Code