Skip to content

Commit 7b65b3c

Browse files
authored
Add message for commit retries on failure
1 parent 5c43a72 commit 7b65b3c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

pyiceberg/table/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)