#[non_exhaustive]pub enum TransientKind {
OptimisticConflict,
SerializationFailure,
Deadlock,
PoolTimeout,
ConnectionLost,
UpstreamUnavailable,
Congestion,
Other,
}Expand description
Why a Transient outcome may succeed on retry.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Implementations§
Source§impl TransientKind
impl TransientKind
pub fn as_str(self) -> &'static str
Sourcepub fn is_congestion(self) -> bool
pub fn is_congestion(self) -> bool
A transient that carries no evidence about the operation itself, only
about shared capacity — a retry loop backs off without spending its
budget, where a conflict kind (Deadlock, SerializationFailure,
OptimisticConflict) is evidence the operation can be re-run at
once.
Sourcepub fn is_contention(self) -> bool
pub fn is_contention(self) -> bool
Postgres aborted the attempt because it lost a race with a concurrent
transaction: a deadlock victim (40P01) or a serialization failure
(40001). Two things follow that no other transient guarantees. The
server confirmed the rollback, so the attempt is safe to re-run even
when the failure surfaced at COMMIT, where any other error is
ambiguous. And the failure says nothing about the data involved, only
about the interleaving, so there is nothing in it to attribute to one
row or to bisect for.
OptimisticConflict is deliberately not contention: it is raised
above Postgres by a version check and names one stale row, so a batch
search can isolate it, and a plain re-run with the same stale state
would only conflict again.
Sourcepub fn from_sqlstate(code: &str) -> Option<TransientKind>
pub fn from_sqlstate(code: &str) -> Option<TransientKind>
The one row of the sqlx lane table (sqlx.rs, private) a consumer
with a non-sqlx Postgres driver could still want: which
TransientKind a Postgres SQLSTATE code maps to, independent of
sqlx::Error. Lives here, not behind the sqlx feature, so it is
reachable without that dependency.
Trait Implementations§
Source§impl Clone for TransientKind
impl Clone for TransientKind
Source§fn clone(&self) -> TransientKind
fn clone(&self) -> TransientKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TransientKind
Source§impl Debug for TransientKind
impl Debug for TransientKind
Source§impl Display for TransientKind
impl Display for TransientKind
impl Eq for TransientKind
Source§impl Hash for TransientKind
impl Hash for TransientKind
Source§impl PartialEq for TransientKind
impl PartialEq for TransientKind
impl StructuralPartialEq for TransientKind
Auto Trait Implementations§
impl Freeze for TransientKind
impl RefUnwindSafe for TransientKind
impl Send for TransientKind
impl Sync for TransientKind
impl Unpin for TransientKind
impl UnsafeUnpin for TransientKind
impl UnwindSafe for TransientKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more