edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

Make save transaction-friendly

Open vpetrovykh opened this issue 5 months ago • 1 comments

We need to make save() (and potentially sync()) transactions-friendly.

By default we don't want save() functionality to produce partial results, instead it is intended as an atomic all-or-nothing operation. Since it's not always possible to pack the necessary operations into a single query we may use a transaction internally to make save() atomic. We don't have nested transactions in Gel, so this behaviour of save() is not compatible with being nested inside another transaction.

We need to automatically detect whether we're in a transaction already and use savepoints when needed for save() to allow rolling back changes in case of save errors without breaking the outer transaction overall.

vpetrovykh avatar Aug 08 '25 10:08 vpetrovykh

The really hairy thing about making this work is dealing with the case where the outer transaction needs to retry. That will be pretty cursed for sync, I think, because we would want to rollback the changes we read back

msullivan avatar Aug 21 '25 21:08 msullivan