#[non_exhaustive]pub enum TxConflict {
Serialization,
Deadlock,
LockTimeout,
Busy,
}Expand description
A concurrency conflict the engine raised: this transaction lost, and the only correct response is to run the whole thing again.
The point of the type is that it is matchable. Serialization failures
arrive as engine-specific codes on engine-specific error types; without a
classification a caller ends up matching on message text, which is a bug
waiting for a locale or a version bump. A backend that reports one of
these constructs a TxConflictError; a caller asks TxConflict::of.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Serialization
The engine could not serialize this transaction against a concurrent
one — PostgreSQL 40001 (could not serialize access …).
Deadlock
A deadlock was detected and this transaction was picked as the victim
— PostgreSQL 40P01, MySQL 1213 (ER_LOCK_DEADLOCK, SQLSTATE
40001: InnoDB reports its serialization failures this way).
LockTimeout
A lock wait timed out — PostgreSQL 55P03, MySQL 1205
(ER_LOCK_WAIT_TIMEOUT).
Busy
SQLite could not take the lock it needed — SQLITE_BUSY /
SQLITE_LOCKED, which is how SQLite says “serialize elsewhere”.
Implementations§
Source§impl TxConflict
impl TxConflict
Sourcepub fn of(e: &ExecError) -> Option<TxConflict>
pub fn of(e: &ExecError) -> Option<TxConflict>
Classify an error: Some when a backend reported a concurrency
conflict, None otherwise. Every variant means the same thing to a
caller — retry the transaction from the top.
Trait Implementations§
Source§impl Clone for TxConflict
impl Clone for TxConflict
Source§fn clone(&self) -> TxConflict
fn clone(&self) -> TxConflict
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more