GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: retry 'job exceeded rate limits' for DDL queries by kiraksi · Pull Request #1794 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@kiraksi

@kiraksi kiraksi commented Jan 19, 2024

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1790 🦕

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kiraksi
fix: retry 'job exceeded rate limits' for DDL queries
5861ba2
@product-auto-label product-auto-label Bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery API. labels Jan 19, 2024
@kiraksi
kiraksi marked this pull request as ready for review January 19, 2024 23:46
@kiraksi
kiraksi requested review from a team, PhongChuong, chalmerlowe and tswast and removed request for PhongChuong January 19, 2024 23:46
tswast
tswast suggested changes Jan 22, 2024
View reviewed changes

@tswast tswast left a comment

Copy link
Copy Markdown
Contributor

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.

Thanks!

I have some feedback regarding testing. I think it may make more sense to follow the pattern I use here, instead:

python-bigquery/tests/unit/test__job_helpers.py

Lines 388 to 447 in 1f96439

def test_query_and_wait_retries_job():
freezegun.freeze_time(auto_tick_seconds=100)
client = mock.create_autospec(Client)
client._call_api.__name__ = "_call_api"
client._call_api.__qualname__ = "Client._call_api"
client._call_api.__annotations__ = {}
client._call_api.__type_params__ = ()
client._call_api.side_effect = (
google.api_core.exceptions.BadGateway("retry me"),
google.api_core.exceptions.InternalServerError("job_retry me"),
google.api_core.exceptions.BadGateway("retry me"),
{
"jobReference": {
"projectId": "response-project",
"jobId": "abc",
"location": "response-location",
},
"jobComplete": True,
"schema": {
"fields": [
{"name": "full_name", "type": "STRING", "mode": "REQUIRED"},
{"name": "age", "type": "INT64", "mode": "NULLABLE"},
],
},
"rows": [
{"f": [{"v": "Whillma Phlyntstone"}, {"v": "27"}]},
{"f": [{"v": "Bhetty Rhubble"}, {"v": "28"}]},
{"f": [{"v": "Phred Phlyntstone"}, {"v": "32"}]},
{"f": [{"v": "Bharney Rhubble"}, {"v": "33"}]},
],
},
)
rows = _job_helpers.query_and_wait(
client,
query="SELECT 1",
location="request-location",
project="request-project",
job_config=None,
page_size=None,
max_results=None,
retry=retries.Retry(
lambda exc: isinstance(exc, google.api_core.exceptions.BadGateway),
multiplier=1.0,
).with_deadline(
200.0
), # Since auto_tick_seconds is 100, we should get at least 1 retry.
job_retry=retries.Retry(
lambda exc: isinstance(exc, google.api_core.exceptions.InternalServerError),
multiplier=1.0,
).with_deadline(600.0),
)
assert len(list(rows)) == 4
# For this code path, where the query has finished immediately, we should
# only be calling the jobs.query API and no other request path.
request_path = "/projects/request-project/queries"
for call in client._call_api.call_args_list:
_, kwargs = call
assert kwargs["method"] == "POST"
assert kwargs["path"] == request_path

It may make sense to also add a test for just the predicate itself:

python-bigquery/tests/unit/test_retry.py

Line 109 in 1f96439

def test_DEFAULT_JOB_RETRY_predicate():

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kiraksi reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kiraksi
Fixed retry test logic to better align to library standards
ef36bf2
@kiraksi
kiraksi force-pushed the job-rate-limit branch from 2db8bf4 to ef36bf2 Compare January 22, 2024 22:38
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jan 22, 2024
kiraksi added 2 commits January 22, 2024 14:41
@kiraksi
added docstring for test
7ce7bad
@kiraksi
deleted extra coverage file
fd28904
@kiraksi
kiraksi force-pushed the job-rate-limit branch from ce34c69 to fd28904 Compare January 22, 2024 22:48
@kiraksi
Merge branch 'main' into job-rate-limit
9874d86
@kiraksi
kiraksi requested a review from tswast January 22, 2024 22:56
tswast
tswast reviewed Jan 23, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tswast
tswast reviewed Jan 23, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tswast
tswast reviewed Jan 23, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

kiraksi and others added 3 commits January 23, 2024 12:22
@kiraksi @tswast
Update tests/unit/test_job_retry.py
b39d77f
Co-authored-by: Tim Swast <[email protected]>
@kiraksi
requested changes to retry jobs test
2f56081
@kiraksi
slight change to assert statemet
ffd6e38
@kiraksi
kiraksi force-pushed the job-rate-limit branch from 89a1bd3 to ffd6e38 Compare January 24, 2024 09:34
tswast
tswast reviewed Jan 24, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tswast
tswast reviewed Jan 24, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Outdated

_, kwargs = calls[2]
assert kwargs["method"] == "POST"
assert kwargs["path"].startswith(response_path)

@tswast tswast Jan 24, 2024

Copy link
Copy Markdown
Contributor

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.

This is an interesting one. Not sure why we'd be doing a POST to this path. That'd indicate that we are doing a jobs insert call, which really shouldn't be happening.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kiraksi kiraksi Jan 24, 2024

Copy link
Copy Markdown
Contributor Author

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.

Added a todo statement for the fix in #1797

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tswast
tswast reviewed Jan 24, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tswast
tswast reviewed Jan 24, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kiraksi
added TODO statements and fixed default job retry
0d0e2f5
@kiraksi
kiraksi force-pushed the job-rate-limit branch from 46f43a5 to 0d0e2f5 Compare January 24, 2024 19:08
kiraksi added 3 commits January 24, 2024 11:08
@kiraksi
Merge branch 'main' into job-rate-limit
c72835a
@kiraksi
modify sleep time and path names
503fb8c
@kiraksi
Merge branch 'main' into job-rate-limit
5590b72
@kiraksi
kiraksi requested a review from tswast January 24, 2024 21:28
tswast
tswast approved these changes Jan 24, 2024
View reviewed changes

@tswast tswast left a comment

Copy link
Copy Markdown
Contributor

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.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kiraksi
kiraksi enabled auto-merge (squash) January 24, 2024 21:42
@kiraksi
kiraksi merged commit 39f33b2 into googleapis:main Jan 24, 2024
@release-please release-please Bot mentioned this pull request Jan 24, 2024
chore(main): release 3.17.1 #1798
Merged
@nlenepveu nlenepveu mentioned this pull request Jan 24, 2024
test: prevent alchemy test suite from being rate-limited. googleapis/python-bigquery-sqlalchemy#1009
Closed
3 of 4 tasks
@nlenepveu

nlenepveu commented Jan 24, 2024

Copy link
Copy Markdown

Thanks @kiraksi!

kiraksi reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kiraksi
kiraksi deleted the job-rate-limit branch January 24, 2024 23:22
tswast
tswast reviewed Jan 25, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tswast
tswast reviewed Jan 25, 2024
View reviewed changes
Comment thread tests/unit/test_job_retry.py

from google.cloud.bigquery.client import Client
from google.cloud.bigquery import _job_helpers
from google.cloud.bigquery.retry import DEFAULT_JOB_RETRY

@tswast tswast Jan 25, 2024

Copy link
Copy Markdown
Contributor

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.

Import modules not classes / methods.

https://google.github.io/styleguide/pyguide.html#22-imports

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kiraksi
kiraksi restored the job-rate-limit branch January 25, 2024 16:18
@kiraksi
kiraksi deleted the job-rate-limit branch January 25, 2024 16:28
This was referenced Jan 30, 2024
January 29, 2024 kitta65/bq-extension-vscode#273
Closed
January 29, 2024 kitta65/prettier-plugin-bq#287
Closed
January 29, 2024 kitta65/bq2cst#287
Closed
@tswast tswast mentioned this pull request Apr 16, 2024
perf: don't retry getQueryResults as often with ambiguous errors in QueryJob.result() googleapis/google-cloud-python#15714
Open
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@chalmerlowe chalmerlowe Awaiting requested review from chalmerlowe
1 more reviewer
@tswast tswast tswast approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

bug: client doesn't retry "Job exceeded rate limits" for DDL query jobs that exceed quota for table update operations

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@kiraksi @nlenepveu @tswast
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.