mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 17:47:28 +00:00
`run_write_interaction` is the Rust `runInteraction` for writes: a `REPEATABLE READ` transaction, committed at the end, and run again from the start on a serialization failure, a deadlock, a cancelled statement or a lost connection, up to five attempts as in Python. Constraint violations come back as their own error, so an expected conflict can be told apart. Once a statement fails, Postgres has aborted the transaction, and a COMMIT would roll back without an error. So if the closure catches a statement error and returns success, the commit is refused with an error. `WriteTxn::insert_many` and `upsert_many` write a batch in one statement whatever its size, passing each column as an array to `UNNEST`. `execute_batch` pipelines a per-row statement for the inserts that need a sub-select per row. The tests run against a real server when `SYNAPSE_TEST_POSTGRES_DSN` is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHKYPSc37kWqGACn9aKxKL