Cancel the Redshift statement when a user kills the deferred task#69676
Open
steveahnahn wants to merge 1 commit into
Open
Cancel the Redshift statement when a user kills the deferred task#69676steveahnahn wants to merge 1 commit into
steveahnahn wants to merge 1 commit into
Conversation
A deferred RedshiftDataOperator parks its query in the triggerer, so the operator's own on_kill no longer runs once the task is deferred. When a user marks that task failed, clears it, or marks it success, the trigger had no on_kill hook, so the Redshift statement kept running against the cluster or workgroup even though the operator already cancels the statement on kill in the non-deferred path. On Redshift Serverless a runaway statement keeps billing RPU-hours, and on a provisioned cluster it holds a WLM slot, until it finishes on its own. This adds on_kill to RedshiftDataTrigger to cancel the running statement when the user acts on the deferred task, matching the behaviour already shipped for the EMR, Dataproc, BigQuery, and Dataflow triggers. A cancel_on_kill flag on both the operator and the trigger lets users opt out.
steveahnahn
force-pushed
the
redshift-cancel-statement-on-user-kill-deferred
branch
from
July 10, 2026 19:54
02ddfa7 to
af96bfc
Compare
steveahnahn
marked this pull request as ready for review
July 10, 2026 22:59
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.
Problem
RedshiftDataOperator.on_killcancels the running statement, but afterdefer()the worker is gone and it can never run.RedshiftDataTriggerhad noon_kill(base default is a no op), so killing a deferred task orphans the statement: RPU hours keep billing on Serverless, a WLM slot stays held on a provisioned cluster.Change
on_killtoRedshiftDataTrigger: cancels via the hook's async connection (cancel_statement).CancelStatementreturns{"Status": bool}; a declined cancel (statement already finished) logs a warning instead of claiming success.cancel_on_killflag (defaultTrue) on operator and trigger; operator threads it into the trigger at the defer site.Live verification
STARTED); taskdeferred, trigger polling via the real aiobotocore client.DescribeStatementreturnedStatus: ABORTED. Without the change the statement staysSTARTED(baseon_killis a no op).Tests
StatusTrue/Falsewith the real response shape), disabled/missing id no ops, error swallowing, serialization of the flag.cancel_on_kill=Falseguard, flag threaded into the trigger on defer (bothTrueandFalse).Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Fable 5) following the guidelines