Repository navigation
Cancel the BigQuery job when BigQueryToGCSOperator is killed - #74564
Conversation
There was a problem hiding this comment.
Thanks for adding the retry caveat to the docstring — that addresses my earlier comment. The change is correct and matches BigQueryInsertJobOperator; one changelog note for the new sync-mode default, plus two optional nits.
Smaller observations
Changelog note (minor). In sync mode, killing the task (includingexecution_timeout) now cancels the extract job by default, where before the job kept running. Users who pair retries withreattach_states(for example{"PENDING", "RUNNING"}) and the defaultforce_rerun=Falsewill see their retry fail with "already exists and is in DONE state" instead of reattaching. The PR body already has the right text ("Users who relied on the job finishing after a kill in sync mode can set cancel_on_kill=False"); it belongs in a short.. warning::under theChangelogheader ofproviders/google/docs/changelog.rst, like theGCSToSFTPOperatornote already there.
Human edit: I think that it could be treated as a feature, so no need for a special changelog entry.
- See inline comments on
providers/google/src/airflow/providers/google/cloud/transfers/bigquery_to_gcs.py:307,providers/google/tests/unit/google/cloud/transfers/test_bigquery_to_gcs.py:213.
^ the above can be addressed in a separate PR, merging as-is.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The findings
below are observations, not blockers; an Apache Airflow
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.More on how Apache Airflow handles maintainer review:
Contributing guide.
BigQueryToGCSOperatorhad noon_kill, so killing the task in sync mode left the extract job running in BigQuery. In deferrable mode the trigger already cancels it, becauseBigQueryInsertJobTriggerdefaults tocancel_on_kill=True, but there was no way to turn that off.This adds a
cancel_on_killargument (defaultTrue), passes it to the trigger, and adds anon_killthat cancels the job. This matchesBigQueryInsertJobOperatorandGCSToBigQueryOperator, which already take the same argument.Users who relied on the job finishing after a kill in sync mode can set cancel_on_kill=False.
Testing
I ran a sync
BigQueryToGCSOperatorwithexecution_timeout=timedelta(seconds=20). When the timeout hits,on_killnow cancels the extract job, as the task log shows.Before this change the operator had no
on_kill, so nothing cancelled the job when the task timed out and it kept running in BigQuery.Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.