8000 fix(inkless:delete-records): fail DeleteRecords when the cross-tier advance fails [KC-883] by viktorsomogyi · Pull Request #931 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content

fix(inkless:delete-records): fail DeleteRecords when the cross-tier advance fails [KC-883] - #931

Merged
giuseppelillo merged 2 commits into
mainfrom
svv/kc-883-swallowed-advance-failure
Dec 4, 2026
Merged

giuseppelillo merged 2 commits into
mainfrom
svv/kc-883-swallowed-advance-failure

Conversation

@viktorsomogyi
@viktorsomogyi viktorsomogyi commented Dec 2, 2026 •
Copy link
Copy Markdown
Contributor

Summary

After a DeleteRecords on a consolidating diskless partition, the broker advances the cross-tier earliest offset in the control plane. Nothing re-sends that value if the call fails, so the broker now reports the failure instead of returning success. Before this change, EARLIEST stayed stale on every broker and followers kept serving deleted records.

 CrossTierDeleteRecords.advance
   per consolidating partition with errorCode NONE:
+    topic id missing               -> UNKNOWN_TOPIC_OR_PARTITION
+    offset < 0 (unknown HIGH_WATERMARK result) -> keep original result
     otherwise                      -> add to the advance request
   controlPlane.advanceCrossTierLogStartOffset
+    size mismatch                  -> fail all partitions (UNKNOWN_SERVER_ERROR)
     per partition:
       NONE                         -> replace result with stored low watermark
+      NONE without stored offset   -> UNKNOWN_SERVER_ERROR
+      UNKNOWN_TOPIC_OR_PARTITION   -> keep original result (control plane does not track the partition)
+      other error                  -> UNKNOWN_SERVER_ERROR, low watermark INVALID
     cache write-through now happens after the loop
   catch Exception
-    log, return success
+    ControlPlaneUnavailableException -> KAFKA_STORAGE_ERROR (retriable)
+    anything else                    -> UNKNOWN_SERVER_ERROR

The advance is forward-only, so repeating a delete or advance to a fixed offset is idempotent. A HIGH_WATERMARK delete resolves its offset again on each attempt. The upstream switch guard rejects DeleteRecords while the switch is pending or the classic prefix is only on local disks.

Evidence

  • Before: testDeleteRecordsConsolidatingDoesNotReportSuccessWhenCrossTierAdvanceFails (the first version of the test) failed on the old code:
    AssertionFailedError: The client must not see success when the cross-tier earliest was not advanced ==> expected: not equal but was: <0>
    The log showed Failed to advance cross-tier log start offset for diskless-0.
    After: CI on 3526e42f94 passes compilation, SpotBugs, and the cross-tier advancement cases. The Java 17 and Java 25 core-other-and-kafka jobs fail on the same test that expects a pending-switch delete to succeed. The correction checks INVALID_REQUEST and an unchanged local log start for HIGH_WATERMARK during a pending switch. A separate helper test checks that an unknown low watermark skips the advance. Test compilation and Vale pass for the correction; CI hasn't run on the correction yet.
control plane throws ControlPlaneUnavailableException -
8000
> errorCode == KAFKA_STORAGE_ERROR, lowWatermark == INVALID
control plane throws ControlPlaneException            -> errorCode == UNKNOWN_SERVER_ERROR
control plane returns UNKNOWN_TOPIC_OR_PARTITION      -> errorCode == NONE (result kept)
topic id unresolved                                   -> errorCode == UNKNOWN_TOPIC_OR_PARTITION

Merge Danger

Door: two-way

Blast Radius: DeleteRecords on consolidating diskless topics

Known limitation: if the control plane returns UNKNOWN_TOPIC_OR_PARTITION for the advance, the broker keeps the original result for compatibility. The broker doesn't schedule a retry or guarantee reconciliation. EARLIEST can stay stale even though the client receives success.

A control-plane outage now surfaces as an error on these deletes, where it used to be swallowed. The delete can already have advanced the local or WAL log start when the error returns. The AdminClient (DeleteRecordsHandler) retries the delete on its own for the retriable KAFKA_STORAGE_ERROR. For the UNKNOWN_TOPIC_OR_PARTITION from an unresolved topic ID, it refreshes metadata and retries. It returns UNKNOWN_SERVER_ERROR to the caller. A retried HIGH_WATERMARK delete can also trim records produced after the first attempt. During a pending switch, the broker returns INVALID_REQUEST before either delete leg runs. No wire format, config, or on-disk change.

Alternatives

  • Retry the advance through the CrossTierLogStartReporter buffer and keep returning success: not chosen. It heals without admin action, but EARLIEST stays stale until the retry lands, and it adds async wiring and concurrency risk.
  • Fail the response and also enqueue a retry: not chosen. It is the largest change, and clients would see errors for deletes that later complete on their own.
  • Chosen: fail the response. It is the smallest fix, and the caller sees the failure.

Fixes KC-883.

🤖 Generated with Claude Code

@viktorsomogyi
viktorsomogyi force-pushed the svv/kc-883-swallowed-advance-failure branch 5 times, most recently from 40a05d0 to 3526e42 Compare December 4, 2026 11:10
@viktorsomogyi
viktorsomogyi marked this pull request as ready for review December 4, 2026 11:11
@viktorsomogyi
viktorsomogyi requested a balanced review from Copilot December 4, 2026 11:11
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.

🟡 Changes recommended

The test expects deletion success during a pending classic-to-diskless switch, but the implementation returns INVALID_REQUEST before deletion, invalidating its success and log-start assertions.

1 open issue
What changed in this PR

This PR makes DeleteRecords report cross-tier offset advance failures for consolidating diskless partitions instead of returning success with stale earliest offsets.

Changes:

  • Extracts cross-tier advancement into a dedicated helper.
  • Validates responses and maps failures to partition errors.
  • Adds coverage for failure handling and partition edge cases.
File Description
core/​src/​test/​scala/​unit/​kafka/​server/​ReplicaManagerInklessTest.scala Adds error, malformed-response, mixed-batch, and pending-switch tests.
core/​src/​main/​scala/​kafka/​server/​ReplicaManager.scala Delegates advancement to the helper and clarifies cleanup comments.
core/​src/​main/​scala/​io/​aiven/​inkless/​consolidation/​CrossTierDeleteRecords.scala Implements response validation, failure mapping, and cache updates.

Review effort: Balanced

@viktorsomogyi
viktorsomogyi force-pushed the svv/kc-883-swallowed-advance-failure branch 2 times, most recently from d7cdf8c to 46d1f86 Compare December 4, 2026 13:01
@viktorsomogyi
viktorsomogyi requested a balanced review from Copilot December 4, 2026 13:01
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.

🟢 Approval recommended

No active review issues remain for the cross-tier DeleteRecords error-handling changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@giuseppelillo
giuseppelillo enabled auto-merge (squash) December 4, 2026 14:59
… fails [KC-883]

A failed cross-tier earliest-offset advance previously left DeleteRecords reporting success, with no mechanism to resend the value. Other brokers could retain a stale earliest offset and continue serving deleted records.

Return a partition error with an invalid low watermark when advancement fails. Map an unavailable control plane to retriable KAFKA_STORAGE_ERROR and other advance failures to UNKNOWN_SERVER_ERROR. Preserve the original results for untracked partitions and pending-switch deletes with an unknown low watermark. Validate response counts and stored offsets before writing through the cache.

Keep the cross-tier advancement logic in an Inkless helper so ReplicaManager stays within the SpotBugs analysis size limit. Clarify caller retry behavior, pending-switch routing, and the control-plane reclaim floor used for remote cleanup.

Validation: :core:spotbugsMain, make vale, and git diff --check pass. No local tests run.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Sonnet 5.5
Assisted-by: GPT-6.1 Sol
…own watermark

The rebased broker rejects DeleteRecords if a classic-to-diskless switch is pending. Cover HIGH_WATERMARK in the existing switch-race test and exercise the unknown low watermark guard directly in the cross-tier advance helper.

Assisted-by: GPT-6.2 Sol
@viktorsomogyi
viktorsomogyi force-pushed the svv/kc-883-swallowed-advance-failure branch from 46d1f86 to 6e80c30 Compare December 4, 2026 15:02
@giuseppelillo
giuseppelillo merged commit d22c2d9 into main Dec 4, 2026
13 checks passed
@giuseppelillo
giuseppelillo deleted the svv/kc-883-swallowed-advance-failure branch December 4, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet
4EBD

Development

Successfully merging this pull request may close these issues.

3 participants

0