Skip to main content

with_transaction_retry

Function with_transaction_retry 

Source
pub async fn with_transaction_retry<C, F, T, E, P>(
    db: &C,
    config: &RetryConfig,
    operation: F,
    should_retry: P,
) -> Result<T, E>
where C: TransactionTrait, F: for<'txn> FnMut(&'txn C::Transaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'txn>>, E: From<DbError> + Display, P: Fn(&E) -> bool,
Expand description

Runs a complete transaction boundary with bounded retries selected by the product.

The callback is rerun only after rollback or a commit failure known to have rolled back the transaction. Any commit error with an uncertain server-side outcome is returned as DbError::CommitOutcomeUnknown, because the server may have committed the transaction even though the client did not receive a success response.

Use crate::retry::RetryConfig::deadlock as the config profile: deadlock and serialization conflicts resolve inside short lock-wait windows, so the fast profile fits.