Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry 400s during dataset teardown. #2333

Merged
merged 2 commits into from
Sep 16, 2016
Merged

Retry 400s during dataset teardown. #2333

merged 2 commits into from
Sep 16, 2016

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented Sep 16, 2016

Closes #2318.

@tseaver tseaver added api: bigquery Issues related to the BigQuery API. flaky labels Sep 16, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 16, 2016
for doomed in self.to_delete:
if isinstance(doomed, Bucket):
retry = RetryErrors(Conflict)
retry(doomed.delete)(force=True)
retry_409 = RetryErrors(Conflict)

This comment was marked as spam.

This comment was marked as spam.

else:
doomed.delete()
retry_400(doomed.delete)()

This comment was marked as spam.

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented Sep 16, 2016

@tseaver Were you able to reproduce this locally?

@tseaver
Copy link
Contributor Author

tseaver commented Sep 16, 2016

Were you able to reproduce this locally?

Not except by borking the delete of tables in the dataset.

@dhermes
Copy link
Contributor

dhermes commented Sep 16, 2016

Gotcher. Thanks for the tip. Can you add an error predicate, e.g.

def err_pred(exc):
    return (len(exc._errors) == 1 and 
            exc._errors[0]['reason'] == 'resourceInUse')

Here is the output from catching that error:

>>> try:
...     dataset.delete()
... except Exception as exc:
...     pass
...
>>> import json
>>> print(json.dumps(exc.__dict__, indent=2))
{
  "message": "Dataset {PROJ}:create_table{TESTID} is still in use (DELETE https://www.googleapis.com/bigquery/v2/projects/{PROJ}/datasets/create_table{TESTID})",
  "_errors": [
    {
      "domain": "global",
      "message": "Dataset {PROJ}:create_table{TESTID} is still in use",
      "reason": "resourceInUse"
    }
  ]
}

Copy link
Contributor

@dhermes dhermes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tseaver tseaver merged commit 613361c into googleapis:master Sep 16, 2016
@tseaver tseaver deleted the 2318-bigquery-dataset-still-in-use branch September 16, 2016 22:21
@dhermes dhermes mentioned this pull request Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants