Skip to content

Commit a34aeef

Browse files
committed
Add logic to skip hive lock wait if retries are set to 0
1 parent 7b65b3c commit a34aeef

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

pyiceberg/catalog/hive.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ def _do_wait_for_lock() -> LockResponse:
488488
f"Failed to check lock for {database_name}.{table_name}, lock state: {response.state}"
489489
)
490490

491+
if not self._lock_check_retries:
492+
raise CommitFailedException(f"Lock was not acquired for commit and retries are set to `0`.")
493+
491494
return _do_wait_for_lock()
492495

493496
def commit_table(

pyiceberg/table/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ def _error_callback(state: RetryCallState):
825825
@wraps(self.commit_transaction)
826826
@retry(
827827
wait=wait_random_exponential(min=min_wait_ms / 1000, max=max_wait_ms / 1000),
828-
stop=stop_after_attempt(num_retries),
828+
stop=stop_after_attempt(num_retries + 1),
829829
retry=retry_if_exception_type(CommitFailedException),
830830
before=_before_attempt,
831831
retry_error_callback=_error_callback,

0 commit comments

Comments
 (0)