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

[GCP-8480] Bigtable: 'test_bigtable_create_table' snippet flakes with '504 Deadline Exceeded'. #16

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bigtable/docs/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,18 @@ def test_bigtable_create_table():
table = instance.table("table_my")
# Define the GC policy to retain only the most recent 2 versions.
max_versions_rule = column_family.MaxVersionsGCRule(2)
table.create(column_families={"cf1": max_versions_rule})

RETRIES = 4
# Retry if deadline exceed error.
for retry in range(RETRIES):
try:
table.create(column_families={"cf1": max_versions_rule})
break
except Exception as e:

Choose a reason for hiding this comment

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

Maybe that is worth it, if possible, to determine the exception more specifically, instead of rising it through Exception?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree on that, this should be under question. Exception is a base class for all exceptions in Python, so with this statement you'll catch errors of all kinds, while in issue they talk only about google.api_core.exceptions.DeadlineExceeded.

if retry == RETRIES - 1:
raise e
else:
time.sleep(2 ** (retry - 1))
# [END bigtable_create_table]

try:
Expand Down