Skip to content

KAFKA-20148: Wait for remote log task completion before cleanup - #23025

Open
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-20148-remote-task-cancellation
Open

KAFKA-20148: Wait for remote log task completion before cleanup#23025
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-20148-remote-task-cancellation

Conversation

@lh0156

@lh0156 lh0156 commented Aug 2, 2026

Copy link
Copy Markdown

Problem

When remote storage is disabled, partition tasks are cancelled while an expiration run may still be scanning remote metadata. The scan can then publish a stale log-start-offset update after cancellation, racing with partition cleanup.

Solution

  • Serialize each remote-log task execution with its cancellation completion path.
  • Interrupt the scheduled future and wait for any in-flight execution before stopPartitions continues cleanup.
  • Make cancellation take precedence over a pending expiration log-start-offset update.

Testing

  • RED: testExpirationDoesNotAdvanceLogStartOffsetAfterCancellation failed against the baseline because the cancelled task advanced the offset to 100.
  • GREEN: the regression test passes after the fix.
  • ./gradlew :storage:test --tests org.apache.kafka.server.log.remote.storage.RemoteLogManagerTest.testExpirationDoesNotAdvanceLogStartOffsetAfterCancellation --no-build-cache --console=plain
  • ./gradlew :storage:test --tests org.apache.kafka.server.log.remote.storage.RemoteLogManagerTest --no-build-cache --console=plain
  • ./gradlew :storage:checkstyleTest :storage:spotlessCheck :storage:spotbugsMain --no-build-cache --console=plain
  • Full :storage:check completed 1,252 tests with one timeout in TransactionsWithTieredStoreTest.testFailureToFenceEpochWithTV1; the same test passed when rerun in isolation, so the result is recorded as local parallel-test variability rather than a changed-path failure.

Fixes KAFKA-20148

Ensure a remote log task has finished its in-flight execution before partition cleanup continues. A cancelled expiration task also skips its pending log-start-offset update, preventing stale retention results from racing with remote storage disablement.

Generated-by: OpenAI Codex (GPT-5)
@github-actions github-actions Bot added triage PRs from the community storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature labels Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage Pull requests that target the storage module tiered-storage Related to the Tiered Storage feature triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant