|
52 | 52 | ) |
53 | 53 | from hive_metastore.ttypes import Database as HiveDatabase |
54 | 54 | from hive_metastore.ttypes import Table as HiveTable |
55 | | -from tenacity import RetryCallState, retry, retry_if_exception_type, stop_after_attempt, wait_exponential |
| 55 | +from tenacity import RetryCallState, retry, retry_if_exception_type, stop_after_attempt, wait_random_exponential |
56 | 56 | from thrift.protocol import TBinaryProtocol |
57 | 57 | from thrift.transport import TSocket, TTransport |
58 | 58 |
|
|
132 | 132 | LOCK_CHECK_MIN_WAIT_TIME = "lock-check-min-wait-time" |
133 | 133 | LOCK_CHECK_MAX_WAIT_TIME = "lock-check-max-wait-time" |
134 | 134 | LOCK_CHECK_RETRIES = "lock-check-retries" |
135 | | -DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 0.1 # 100 milliseconds |
136 | | -DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 60 # 1 min |
137 | | -DEFAULT_LOCK_CHECK_RETRIES = 4 |
| 135 | +DEFAULT_LOCK_CHECK_MIN_WAIT_TIME = 1 # 1 second |
| 136 | +DEFAULT_LOCK_CHECK_MAX_WAIT_TIME = 5 # 5 seconds |
| 137 | +DEFAULT_LOCK_CHECK_RETRIES = 32 |
138 | 138 |
|
139 | 139 |
|
140 | 140 | logger = get_logger(__name__) |
@@ -471,7 +471,7 @@ def _on_wait_for_lock_fail(state: RetryCallState) -> None: |
471 | 471 |
|
472 | 472 | @retry( |
473 | 473 | retry=retry_if_exception_type(WaitingForLockException), |
474 | | - wait=wait_exponential(multiplier=2, min=self._lock_check_min_wait_time, max=self._lock_check_max_wait_time), |
| 474 | + wait=wait_random_exponential(multiplier=2, min=self._lock_check_min_wait_time, max=self._lock_check_max_wait_time), |
475 | 475 | stop=stop_after_attempt(self._lock_check_retries), |
476 | 476 | before=lambda state: logger.debug(f"({state.attempt_number}) Waiting on lock for `{database_name}.{table_name}`..."), |
477 | 477 | retry_error_callback=_on_wait_for_lock_fail, |
|
0 commit comments