0BVer opened a new pull request, #77226:
URL: https://github.com/apache/airflow/pull/77226

   `BigQueryInsertJobOperator` waits for its job with 
`job.result(timeout=self.result_timeout)`, and `result_timeout` defaults to 
`None`. python-bigquery treats an explicit `None` as "no request timeout", so 
one `jobs.getQueryResults` response that never arrives blocks the read forever. 
The BigQuery job has already finished, but the task keeps running until 
`execution_timeout` (unset by default) or a manual kill. In production this 
kept a Dag run running for more than four hours after a BigQuery job that took 
1m23s, and it has happened again since.
   
   When `result_timeout` is not set, the operator now calls `job.result` with a 
120 second timeout and calls it again whenever it raises `TimeoutError`. Every 
call is bounded and the total wait stays unlimited, as before. An explicit 
`result_timeout` behaves as it did.
   
   120 seconds is the minimum request timeout python-bigquery already applies 
to `getQueryResults`, so a slice is never shorter than one request.
   
   `test_execute_reattach` asserted `timeout=None`, which is the behaviour this 
PR removes, so it now asserts that a timeout is passed.
   
   The unbounded request comes from how python-bigquery handles an omitted or 
`None` timeout, tracked in googleapis/google-cloud-python#18857. Other call 
sites that call `job.result()` without a timeout, such as the check operators 
and `BigQueryHook.insert_job` with `nowait=False`, share that exposure and are 
not changed here.
   
   ##### How this was checked
   
   Run in Breeze (Python 3.11, google-cloud-bigquery 3.47.0):
   
   - The real operator against a mock BigQuery REST server that never answers 
the first `getQueryResults`. The job is `DONE` at 0.7s.
     - Before: the task is still running after 200s.
     - After: the task finishes at 121.0s, when the lost request times out and 
is retried.
   - `providers/google/tests/unit/google/cloud/operators/test_bigquery.py`: 181 
passed. With the source reverted to `main`, `test_execute_reattach` and 
`test_waits_in_bounded_slices_when_result_timeout_is_unset` fail.
   - `providers/google/tests/unit/google/cloud/openlineage/test_mixins.py`: 65 
passed.
   - `breeze run mypy` on the two changed files: no issues.
   - `prek run --from-ref origin/main` for the `pre-commit` and `manual` 
stages, skipping the hooks `AGENTS.md` says to skip: passed.
   
   The rest of the `breeze verify` list (other providers, docs build) is left 
to CI.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (Claude Code, Sonnet 5.5)
   
   Generated-by: Claude Code (Sonnet 5.5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to