Retry once on "invalid snapshot time" when publishing views (#1095)
Fixes #1001
This commit is contained in:
Родитель
371f47e55b
Коммит
9422909cfd
|
@ -8,7 +8,9 @@ import logging
|
|||
from multiprocessing.pool import ThreadPool
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from google.api_core.exceptions import BadRequest
|
||||
from google.cloud import bigquery
|
||||
import sqlparse
|
||||
|
||||
|
@ -58,7 +60,17 @@ def process_file(client, args, filepath):
|
|||
if args.dry_run:
|
||||
print(f"Validated definition of {target_view} in {filepath}")
|
||||
else:
|
||||
query_job.result()
|
||||
try:
|
||||
query_job.result()
|
||||
except BadRequest as e:
|
||||
if "Invalid snapshot time" in e.message:
|
||||
# This occasionally happens due to dependent views being
|
||||
# published concurrently; we wait briefly and give it one
|
||||
# extra try in this situation.
|
||||
time.sleep(1)
|
||||
client.query(sql, job_config).result()
|
||||
else:
|
||||
raise
|
||||
print(f"Published view {target_view}")
|
||||
else:
|
||||
print(
|
||||
|
|
Загрузка…
Ссылка в новой задаче