Skip to main content

get_by_ids_for_update

Function get_by_ids_for_update 

Source
pub async fn get_by_ids_for_update(
    conn: &mut PgConnection,
    ids: &[Uuid],
) -> ModelResult<Vec<CreditRegistration>>
Expand description

The named rows, locked until the caller’s transaction ends. Must be called inside one.

For a caller that judges each row and then transitions it: holding the lock is what keeps the judgement true, so transition’s expected_from_state cannot fail halfway and roll the whole batch back. Locks in id order, which every batch caller shares, so two of them cannot deadlock.