Bedrock.Internal.Repo (bedrock v0.7.0)
View SourceSummary
Functions
Create a lazy stream for a range query.
The delay before retry number retry_count, in milliseconds.
Executes a function within a transaction context with automatic retry logic.
Types
Functions
Create a lazy stream for a range query.
Options
:batch_size- Number of items to fetch per batch (default: 100):timeout- Timeout per batch request (default: 5000):limit- Maximum total items to return
@spec get_range( module(), start_key :: key(), end_key :: key(), opts :: [ batch_size: pos_integer(), timeout: pos_integer(), limit: pos_integer(), mode: :individual | :batch, snapshot: boolean() ] ) :: Enumerable.t({any(), any()})
@spec retry_delay_in_ms(non_neg_integer()) :: pos_integer()
The delay before retry number retry_count, in milliseconds.
FULL JITTER: a uniform draw from the whole interval below a ceiling that doubles, capped. The ceiling schedule is unchanged — what changed is that the delay is drawn from ALL of it rather than from a 3ms band at the top.
That distinction is the whole point. Transactions contending on one key fail at nearly the same instant; if they then compute nearly the same delay they wake together and collide again, and the round trip repeats at twice the delay. Spreading them across the interval means some contender arrives while the key is uncontended instead of every contender re-colliding. Identical 100-way workloads varied 278ms to 2059ms on the old schedule.
This is FDB's client backoff (NativeAPI.actor.cpp:4436:
returnedBackoff *= deterministicRandom()->random01(), with the
ceiling grown at :4446 by BACKOFF_GROWTH_RATE). Never zero, so a
retry can never become a spin.
@spec select(module(), Bedrock.KeySelector.t()) :: nil | {resolved_key :: key(), value()}
@spec select(module(), Bedrock.KeySelector.t(), opts :: keyword()) :: nil | {resolved_key :: key(), value()}
@spec transact( cluster :: module(), repo :: module(), (-> result) | (module() -> result), opts :: keyword() ) :: result when result: any()
Executes a function within a transaction context with automatic retry logic.
Options
:retry_limit- Maximum number of retry attempts (default: unlimited):timeout_in_ms- End-to-end transaction timeout, including retries (default: 5000; use:infinityto disable):transaction_system_layout- Use a specific TSL instead of fetching from coordinator