Expand description
Request-scoped transactions for #[Transactional].
§Contract
beginon entering the handler, against the primary of the request-tenant’s pool.- Commit when the handler returns
Ok(..). - Rollback when it returns
Err(..)— and on panic /#[Timeout]expiry, because dropping an uncommitted driver transaction rolls back in every supported ecosystem.
§Zero-lock mechanics
The live transaction rides a tokio::task_local! slot — strictly
per-request-task state, no global registry, no mutex. Services reach it
through with_current_tx, which takes the transaction out of the
slot, awaits the closure, and puts it back — so no RefCell borrow is
ever held across an .await (keeping handler futures Send).
Diesel’s sync core cannot hold a transaction across .await by design;
#[Transactional] therefore rejects Diesel-backed pools at runtime with
a clear error — use DieselBlockingPool::transaction (whole tx inside
one blocking closure) instead.
Enums§
- Arcly
Transaction - One live driver transaction. Dropping without commit rolls back.
Functions§
- in_
transaction truewhen running inside a#[Transactional]scope.- with_
current_ tx - Run
workwith this request’s transaction (if#[Transactional]opened one). The transaction is moved out of the slot for the duration of the closure and put back afterwards, so the future staysSend.