Skip to main content

advance_account_data_sequence

Function advance_account_data_sequence 

Source
pub(crate) async fn advance_account_data_sequence<T: Database + ?Sized>(
    db: &mut T,
    stream_id: i64,
) -> Result<(), DatabaseError>
Expand description

Advances account_data_streamids so its last value covers stream_id, never moving it backwards. Called by the account-data importers after they insert a row carrying a preserved (sequence-bypassing) stream_id, so the next nextval cannot hand out an id that already exists.

setval is non-transactional, so on a rolled-back import batch the sequence may stay advanced, that only ever skips ids forward, which is harmless (stream_ids need only be monotonic, not gap-free).