@@ -45,12 +45,10 @@ var (
45
45
}
46
46
47
47
// Do not include codes.Unavailable here since client already retries for Unavailable error
48
- beginTxnRetryer = gax .OnCodes ([]codes.Code {codes .DeadlineExceeded ,
49
- codes .Internal }, txnBackoff )
50
- rollbackRetryer = gax .OnCodes ([]codes.Code {codes .DeadlineExceeded ,
51
- codes .Internal }, txnBackoff )
52
- txnRetryer = gax .OnCodes ([]codes.Code {codes .Aborted , codes .Canceled , codes .Unknown , codes .DeadlineExceeded ,
53
- codes .Internal , codes .Unauthenticated }, txnBackoff )
48
+ beginTxnRetryCodes = []codes.Code {codes .DeadlineExceeded , codes .Internal }
49
+ rollbackRetryCodes = []codes.Code {codes .DeadlineExceeded , codes .Internal }
50
+ txnRetryCodes = []codes.Code {codes .Aborted , codes .Canceled , codes .Unknown , codes .DeadlineExceeded ,
51
+ codes .Internal , codes .Unauthenticated }
54
52
55
53
gaxSleep = gax .Sleep
56
54
)
@@ -307,7 +305,7 @@ func (c *Client) newTransactionWithRetry(ctx context.Context, s *transactionSett
307
305
return t , newTxnErr
308
306
}
309
307
// Check if BeginTransaction should be retried
310
- if backoffErr := backoffBeforeRetry (ctx , beginTxnRetryer , newTxnErr ); backoffErr != nil {
308
+ if backoffErr := backoffBeforeRetry (ctx , gax . OnCodes ( beginTxnRetryCodes , txnBackoff ) , newTxnErr ); backoffErr != nil {
311
309
return nil , backoffErr
312
310
}
313
311
}
@@ -414,7 +412,7 @@ func (c *Client) RunInTransaction(ctx context.Context, f func(tx *Transaction) e
414
412
}
415
413
} else {
416
414
// Check whether error other than ResourceExhausted should be retried
417
- backoffErr := backoffBeforeRetry (ctx , txnRetryer , retryErr )
415
+ backoffErr := backoffBeforeRetry (ctx , gax . OnCodes ( txnRetryCodes , txnBackoff ) , retryErr )
418
416
if backoffErr != nil {
419
417
return nil , err
420
418
}
@@ -496,7 +494,7 @@ func (t *Transaction) rollbackWithRetry() error {
496
494
}
497
495
498
496
// Check if Rollback should be retried
499
- if backoffErr := backoffBeforeRetry (t .ctx , rollbackRetryer , rollbackErr ); backoffErr != nil {
497
+ if backoffErr := backoffBeforeRetry (t .ctx , gax . OnCodes ( rollbackRetryCodes , txnBackoff ) , rollbackErr ); backoffErr != nil {
500
498
return backoffErr
501
499
}
502
500
}
0 commit comments