@@ -94,16 +94,24 @@ def create_bq_connection(
9494        # https://cloud.google.com/bigquery/docs/reference/standard-sql/remote-functions#grant_permission_on_function 
9595        self ._ensure_iam_binding (project_id , service_account_id , iam_role )
9696
97-     # Introduce retries to accommodate transient errors like etag mismatch, 
98-     # which can be caused by concurrent operation on the same resource, and 
99-     # manifests with message like: 
100-     # google.api_core.exceptions.Aborted: 409 There were concurrent policy 
101-     # changes. Please retry the whole read-modify-write with exponential 
102-     # backoff. The request's ETag '\007\006\003,\264\304\337\272' did not match 
103-     # the current policy's ETag '\007\006\003,\3750&\363'. 
97+     # Introduce retries to accommodate transient errors like: 
98+     # (1) Etag mismatch, 
99+     #     which can be caused by concurrent operation on the same resource, and 
100+     #     manifests with message like: 
101+     #     google.api_core.exceptions.Aborted: 409 There were concurrent policy 
102+     #     changes. Please retry the whole read-modify-write with exponential 
103+     #     backoff. The request's ETag '\007\006\003,\264\304\337\272' did not 
104+     #     match the current policy's ETag '\007\006\003,\3750&\363'. 
105+     # (2) Connection creation, 
106+     #     for which sometimes it takes a bit for its service account to reflect 
107+     #     across APIs (e.g. b/397662004, b/386838767), before which, an attempt 
108+     #     to set an IAM policy for the service account may throw an error like: 
109+     #     google.api_core.exceptions.InvalidArgument: 400 Service account 
110+     #     bqcx-*@gcp-sa-bigquery-condel.iam.gserviceaccount.com does not exist. 
104111    @google .api_core .retry .Retry ( 
105112        predicate = google .api_core .retry .if_exception_type ( 
106-             google .api_core .exceptions .Aborted  
113+             google .api_core .exceptions .Aborted , 
114+             google .api_core .exceptions .InvalidArgument , 
107115        ), 
108116        initial = 10 , 
109117        maximum = 20 , 
0 commit comments