Skip to content

Add a check in BigQueryInsertJobOperator to verify the Job state before marking it as success in Airflow #40839

Closed

Description

@kandharvishnu

Apache Airflow Provider(s)

google

Versions of Apache Airflow Providers

apache-airflow-providers-google==10.12.0

Apache Airflow version

2.7.3

Operating System

debian

Deployment

Astronomer

Deployment details

No response

What happened

When the BigQueryInsertJobOperator submits a job to BigQuery, there are instances where the TaskInstance in Airflow is marked as success rarely before the Job actually completes in BigQuery.

When the execute method of a TaskInstance’s Operator completes without raising an exception, the TaskInstance is marked as success. Since these TaskInstances are being marked as success, it implies that the BigQueryInsertJobOperator’s execute method is completing without any exceptions. When QueryJob.result returns something, allowing the execute method to finish.

What you think should happen instead

Need to add an additional check here to verify if the Job state is DONE in BigQuery, ensuring that Airflow only marks the TaskInstance as success when the job is indeed complete in BigQuery.

How to reproduce

I haven't been able to replicate the issue. It happens infrequently.

Anything else

There might be a bug in google-cloud-bigquery==3.13.0 that causes the QueryJob.result method to return before the job is actually DONE.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Jul 17, 2024

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  2. removed
    needs-triagelabel for new issues that we didn't triage yet
    on Jul 17, 2024
  3. RNHTTR commented on Jul 17, 2024

    @RNHTTR
    Contributor

    Worth noting that even though this is on an older version of the provider, there's no check in main to see whether the job completed in BigQuery. I think this is probably a bug in google-cloud-bigquery==3.13.0, but it still might make sense to check whether the job is complete to avoid this situation completely.

  4. shahar1 commented on Nov 26, 2024

    @shahar1
    Contributor

    @kandharvishnu @pankajastro

    I'd like to have 3 requests:

    1. Could you please decide on continuing the work in a single PR? I'd be happy if you guys could come to an agreement in good terms, it will make the reviewing work much easier :)
    2. Could you please check if upgrading BigQuery's SDK solves the issue?
    3. Could you please raise an issue* about it in BigQuery's Python SDK repository? (and if you're BigQuery users - it would be helpful to also raise a case about it via GCP's console)

    * @eladkal I agree with your statement that we shouldn't work with permanent workarounds - however, would it suffice for now to implement one of the PRs while adding a link to an appropriate issue in Bigquery?

  5. pankajastro commented on Nov 28, 2024

    @pankajastro
    Member

    Hey @shahar1, Thank you for the review feedback I appreciate it. I have added my thoughts and also proposed some modified solutions which might help us in detecting future errors. Please do let me your thought. thank you! #44279 (comment)

  6. eladkal commented on Dec 1, 2024

    @eladkal
    Contributor

    Closed by #44279

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions