Repository navigation
Fix duplicate Dataproc job submission after a triggerer restart - #72685
Merged
Merged
Conversation
DataprocSubmitJobDirectTrigger only learns the job id from the submit response, and nothing carries that id back into the trigger's serialized kwargs. A triggerer that restarts while the job is running therefore re-runs run() from the top and submits a second job, and a kill that lands while the submit call is in flight leaves behind a job that on_kill() has no id to cancel.
The task identity the id was derived from is only unique within one deployment. Two Airflow instances that share a Dataproc project and run the same Dag can converge on the same id, and a metadata database restored from another deployment makes that a certainty rather than a coincidence. The trigger would then take the other deployment's job for its own earlier submission, poll it, and cancel it on kill. The task instance uuid is reissued per try and is unique across deployments, so it carries the whole identity on its own. Airflow 2 has no such column and keeps the task identity as its fallback.
The resume path keyed off self.job_id, which only means "the trigger named this job" for as long as nothing sets that attribute earlier. Setting it from a caller-supplied job reference -- the obvious way to give on_kill() an id for a job the caller named -- would quietly turn the guard into its opposite, and no test covered the branch that refuses to resume.
Whether an AlreadyExists may resume polling has to read as a statement about job id ownership: a job the caller named is never adopted, and one the trigger named always is, whatever request_id happens to be in play. Only two of the four caller id combinations were exercised, so nothing stopped the rule from drifting onto request_id. on_kill() tolerating a NotFound also has to stay narrow, or a kill that cannot reach Dataproc at all would look like a job that was never there.
rjgoyln
force-pushed
the
fix/dataproc-direct-trigger-job-id
branch
from
September 19, 2026 07:14
61dedf6 to
5f1fe79
Compare
rjgoyln
marked this pull request as ready for review
September 19, 2026 07:17
shahar1
approved these changes
Sep 19, 2026
The method is an internal step of run(), not something a Dag author or another provider has any reason to call, and a public name on a trigger class is part of what the provider promises to keep.
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.
Summary
DataprocSubmitJobDirectTrigger— thestart_from_triggerpath ofDataprocSubmitJobOperator— learns the job id only from the submit response, and cannot write it back into the Trigger row it is inflated from. Two ways to lose a job follow:run()and submits a second Dataproc job, leaving the first untrackedon_kill()with no id, so the job it created keeps runningOn Airflow 3.3+ the second symptom also needs #72591, which restores the
CancelledErrorpropagationon_kill()is reached through.Change
request_idto that same idAlreadyExists, but only for a job this trigger namedNotFoundwhen cancelling a job that may never have reached DataprocThe id must be derivable rather than remembered: the Trigger row's kwargs come from
start_trigger_args, so nothing the trigger learns at runtime survives its re-creation. The trigger row id and the task instance uuid are both re-injected from the database on every inflation — the row id pins one deferral, and the uuid is reissued per try, so a retry submits a new job while a restart returns to the old one.Being a uuid, it also separates two deployments that share a Dataproc project. Airflow 2 has no such column and falls back to the task identity, which is unique only within one deployment.
Resuming is decided by the job id alone: a job the caller named is never adopted, whatever
request_idis in play.Behavior change
Jobs submitted through
start_from_triggernow carry an Airflow-assigned id (airflow-<hash>) rather than one generated by Dataproc.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines