aistore.sdk.lock_poller

View as Markdown

Module Contents

Classes

NameDescription
LockPollerBest-effort delay for tenacity retries on read-timeouts during a cold GET.

Data

MIN_WAIT_CEILING

MIN_WAIT_FLOOR

OBJ_SIZE_SCALING_FACTOR

logger

API

class aistore.sdk.lock_poller.LockPoller(
executor: aistore.sdk.request_executor.RequestExecutor,
cold_get_conf: aistore.sdk.retry_config.ColdGetConf
)

Best-effort delay for tenacity retries on read-timeouts during a cold GET.

When a remote-bucket GET request times out, the most likely cause is that an in-flight cold-get is holding the object’s write lock while it streams from the remote backend (e.g., s3). This poller asks the cluster whether the object is currently write-locked. If locked, it polls check-lock with a size-scaled exponential backoff until the object is unlocked or max_cold_wait expires.

This routes all polling requests to the original configured AIStore endpoint for the provided RequestExecutor.

Parameters:

executor
RequestExecutor

Pre-configured executor used for sending requests to AIS

cold_get_conf
ColdGetConf

Configuration determining how to poll AIS for cold-get status

aistore.sdk.lock_poller.LockPoller._create_cold_get_retryer(
size: int
) -> tenacity.Retrying

Build a tenacity Retrying that re-calls a bool-returning function as long as it keeps returning True (i.e. the object stays locked), with a size-scaled exponential backoff capped at max_cold_wait.

aistore.sdk.lock_poller.LockPoller._head_size(
path: str,
params: typing.Dict[str, str]
) -> int

Fresh HEAD via the configured RequestExecutor to retrieve the object size for scaling the poll backoff. Returns 0 on any failure (so the poller falls back to the minimum backoff bounds).

HEAD on a cold-get with write-lock held should fail to load local object metadata. It will fall back to previous cached attributes if the object exists (lock is a new update).

aistore.sdk.lock_poller.LockPoller._is_write_locked(
path: str,
params: typing.Dict[str, str]
) -> bool

POST check-lock via the configured RequestExecutor.

Returns: True iff the target replied 423 (write-locked). False on any other status or on transport error; the caller will then stop delaying and let the outer tenacity retry continue.

aistore.sdk.lock_poller.LockPoller.wait_for_unlock(
req: requests.PreparedRequest
)

Delay until the object referenced by the failed request is no longer write-locked (i.e. any in-flight cold-get has released its lock).

Parameters:

req
PreparedRequest

Request made to AIS target before receiving the initial error.

aistore.sdk.lock_poller.MIN_WAIT_CEILING = 10
aistore.sdk.lock_poller.MIN_WAIT_FLOOR = 2
aistore.sdk.lock_poller.OBJ_SIZE_SCALING_FACTOR = 4
aistore.sdk.lock_poller.logger = get_logger(__name__)