This repository was archived by the owner on Mar 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 324
fix: retry 404 errors in Client.query(...)
#2135
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eb09d8f
fix: retry 404 errors in `Client.query(...)`
tswast 0138de5
retry on 404
tswast c7a8c96
only retry notfound on jobs.insert
tswast cbb2f03
try to improve code coverage
tswast 8e20cb0
disambiguate job not found from dataset/table not found
tswast 0e2d2a9
remove use of private attributes
tswast c0af0d0
fix unit tests
tswast 189f559
fix cover for retry.py
tswast 8ae1213
Merge branch 'main' into issue2134-query404
tswast File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
try to improve code coverage
- Loading branch information
commit cbb2f039d5956c36adce2f3b89747d43ca0cf8a6
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5311,6 +5311,36 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails(self): | |
| with pytest.raises(DataLoss, match="we lost your job, sorry"): | ||
| client.query("SELECT 1;", job_id=None) | ||
|
|
||
| def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails_no_retries(self): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you help me understand what this test is for? It feels like we are just verifying that |
||
| from google.api_core.exceptions import Conflict | ||
| from google.api_core.exceptions import DataLoss | ||
| from google.cloud.bigquery.job import QueryJob | ||
|
|
||
| creds = _make_credentials() | ||
| http = object() | ||
| client = self._make_one(project=self.PROJECT, credentials=creds, _http=http) | ||
|
|
||
| job_create_error = Conflict("Job already exists.") | ||
| job_begin_patcher = mock.patch.object( | ||
| QueryJob, "_begin", side_effect=job_create_error | ||
| ) | ||
| get_job_patcher = mock.patch.object( | ||
| client, "get_job", side_effect=DataLoss("we lost your job, sorry") | ||
| ) | ||
|
|
||
| with job_begin_patcher, get_job_patcher: | ||
| # If get job request fails but supposedly there does exist a job | ||
| # with this ID already, raise the exception explaining why we | ||
| # couldn't recover the job. | ||
| with pytest.raises(DataLoss, match="we lost your job, sorry"): | ||
| client.query( | ||
| "SELECT 1;", | ||
| job_id=None, | ||
| # Explicitly test with no retries to make sure those branches are covered. | ||
| retry=None, | ||
| job_retry=None, | ||
| ) | ||
|
|
||
| def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404(self): | ||
| """Regression test for https://github.com/googleapis/python-bigquery/issues/2134 | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parthea likewise here. I ended up using a slightly different pattern here due to the double nesting of retry objects.