Skip to content

Commit

Permalink
[spanner] fix: set timeout for polling on operations (#3488)
Browse files Browse the repository at this point in the history
* [spanner] fix: set timeout for polling on operations

fixes #3471

* bump the deadline to 1200 for backup and restore

* bumped the deadline to 120
  • Loading branch information
Takashi Matsuo authored Apr 25, 2020
1 parent 0687402 commit 1e072f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions spanner/cloud-client/backup_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create_backup(instance_id, database_id, backup_id):
operation = backup.create()

# Wait for backup operation to complete.
operation.result()
operation.result(1200)

# Verify that the backup is ready.
backup.reload()
Expand All @@ -68,7 +68,7 @@ def restore_database(instance_id, new_database_id, backup_id):
operation = new_database.restore(backup)

# Wait for restore operation to complete.
operation.result()
operation.result(1200)

# Newly created database has restore information.
new_database.reload()
Expand Down
14 changes: 7 additions & 7 deletions spanner/cloud-client/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create_database(instance_id, database_id):
operation = database.create()

print('Waiting for operation to complete...')
operation.result()
operation.result(120)

print('Created database {} on instance {}'.format(
database_id, instance_id))
Expand Down Expand Up @@ -213,7 +213,7 @@ def add_index(instance_id, database_id):
'CREATE INDEX AlbumsByAlbumTitle ON Albums(AlbumTitle)'])

print('Waiting for operation to complete...')
operation.result()
operation.result(120)

print('Added the AlbumsByAlbumTitle index.')
# [END spanner_create_index]
Expand Down Expand Up @@ -306,7 +306,7 @@ def add_storing_index(instance_id, database_id):
'STORING (MarketingBudget)'])

print('Waiting for operation to complete...')
operation.result()
operation.result(120)

print('Added the AlbumsByAlbumTitle2 index.')
# [END spanner_create_storing_index]
Expand Down Expand Up @@ -355,7 +355,7 @@ def add_column(instance_id, database_id):
'ALTER TABLE Albums ADD COLUMN MarketingBudget INT64'])

print('Waiting for operation to complete...')
operation.result()
operation.result(120)

print('Added the MarketingBudget column.')
# [END spanner_add_column]
Expand Down Expand Up @@ -509,7 +509,7 @@ def create_table_with_timestamp(instance_id, database_id):
])

print('Waiting for operation to complete...')
operation.result()
operation.result(120)

print('Created Performances table on database {} on instance {}'.format(
database_id, instance_id))
Expand Down Expand Up @@ -554,7 +554,7 @@ def add_timestamp_column(instance_id, database_id):
'OPTIONS(allow_commit_timestamp=true)'])

print('Waiting for operation to complete...')
operation.result()
operation.result(120)

print('Altered table "Albums" on database {} on instance {}.'.format(
database_id, instance_id))
Expand Down Expand Up @@ -1122,7 +1122,7 @@ def create_table_with_datatypes(instance_id, database_id):
])

print('Waiting for operation to complete...')
operation.result()
operation.result(120)

print('Created Venues table on database {} on instance {}'.format(
database_id, instance_id))
Expand Down

0 comments on commit 1e072f2

Please sign in to comment.