File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -811,13 +811,24 @@ def _before_attempt(state: RetryCallState):
811811 self ._apply (* op ._commit ())
812812 logger .debug (f"Committing transaction..." )
813813
814+ def _error_callback (state : RetryCallState ):
815+ msg = (
816+ f"Failed to commit transaction after { state .attempt_number :,} attempts."
817+ f" Try increasing the value of the `{ COMMIT_NUM_RETRIES } ` property on your table."
818+ )
819+ if state .outcome and (excp := state .outcome .exception ()):
820+ excp .args = (msg + "\n \n " + excp .args [0 ],)
821+ raise excp
822+
823+ raise CommitFailedException (msg )
824+
814825 @wraps (self .commit_transaction )
815826 @retry (
816827 wait = wait_random_exponential (min = min_wait_ms / 1000 , max = max_wait_ms / 1000 ),
817828 stop = stop_after_attempt (num_retries ),
818829 retry = retry_if_exception_type (CommitFailedException ),
819830 before = _before_attempt ,
820- reraise = True ,
831+ retry_error_callback = _error_callback ,
821832 )
822833 def _commit_transaction ():
823834 if len (self ._updates ) > 0 :
You can’t perform that action at this time.
0 commit comments