Multi-collection transactions with optimistic concurrency control.
# Python example
tx = db.begin_transaction()
db.tx_insert(tx, "accounts", {"id": "A", "balance": 1000})
db.tx_update(tx, "accounts", {"id": "B"}, {"$inc": {"balance": -500}})
db.tx_update(tx, "accounts", {"id": "A"}, {"$inc": {"balance": 500}})
db.commit_transaction(tx) # atomic commit or rollback on conflict
| Method | Description |
|---|---|
begin_transaction() | Start a new transaction, returns transaction ID |
tx_insert(tx, col, doc) | Buffered insert |
tx_find(tx, col, query) | Read from committed state (does NOT see same-tx buffered writes — OCC semantics) |
tx_update(tx, col, query, update) | Buffered update |
tx_delete(tx, col, query) | Buffered delete |
commit_transaction(tx) | Validate and commit atomically |
rollback_transaction(tx) | Discard all buffered changes |
When the server runs with --features cluster behind oxipool, transactions are pinned to a single shard for their entire lifetime:
begin_tx grabs a backend connection from the targeted shard's master pool and locks it to that client until commit_tx or rollback_tx.cross-shard transactions not supported; use the same shard key within a transaction.OxiDbRequest::CommitTransaction), replicated to all followers in the shard's Raft group, and ack'd to the client.Practical consequence: pick a shard key your tx data shares (e.g. customer_id for a checkout flow), and the cluster gives you the same atomicity story as standalone mode.