Skip to content

Cancel the BigQuery job when BigQueryToGCSOperator is killed - #74564

Merged
shahar1 merged 2 commits into
apache:mainfrom
yuseok89:bigquery-to-gcs-cancel-on-kill
Oct 17, 2026
Merged

shahar1 merged 2 commits into
apache:mainfrom
yuseok89:bigquery-to-gcs-cancel-on-kill

Conversation

@yuseok89

@yuseok89 yuseok89 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

BigQueryToGCSOperator had no on_kill, so killing the task in sync mode left the extract job running in BigQuery. In deferrable mode the trigger already cancels it, because BigQueryInsertJobTrigger defaults to cancel_on_kill=True, but there was no way to turn that off.

This adds a cancel_on_kill argument (default True), passes it to the trigger, and adds an on_kill that cancels the job. This matches BigQueryInsertJobOperator and GCSToBigQueryOperator, which already take the same argument.

Mode Before After
sync Job keeps running after kill Job is cancelled, unless cancel_on_kill=False
deferrable Job is always cancelled Same by default, can be turned off with cancel_on_kill=False

Users who relied on the job finishing after a kill in sync mode can set cancel_on_kill=False.

Testing

I ran a sync BigQueryToGCSOperator with execution_timeout=timedelta(seconds=20). When the timeout hits, on_kill now cancels the extract job, as the task log shows.

image

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?
  • Yes (please specify the tool below)
    • Claude Code (Opus 5.5)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Oct 12, 2026
@yuseok89
yuseok89 marked this pull request as ready for review October 12, 2026 15:50
@yuseok89
yuseok89 requested a review from shahar1 as a code owner October 12, 2026 15:50

@olegkachur-e olegkachur-e 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.

LGTM 👍

@shahar1 shahar1 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.

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 (including execution_timeout) now cancels the extract job by default, where before the job kept running. Users who pair retries with reattach_states (for example {"PENDING", "RUNNING"}) and the default force_rerun=False will 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 the Changelog header of providers/google/docs/changelog.rst, like the GCSToSFTPOperator note 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.

@shahar1
shahar1 merged commit f3784d2 into apache:main Oct 17, 2026
87 checks passed
@shahar1 shahar1 mentioned this pull request Oct 20, 2026
6 of 7 tasks
SameerMesiah97 pushed a commit to SameerMesiah97/airflow-oss-sm97 that referenced this pull request Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants