Difference between flushing in outer transaction and committing in nested transaction
After introducing nested transactions into our software I was greeted with a flurry of ObjectDeletedErrors. It turned out that it makes a huge difference if a change is committed inside a nested transaction or flushed inside the main transaction.
From the database side I expect these to be equivalent:
begin; -- add stuff to the database rollback;
Updated instructions using nested transactions
begin; savepoint inner; -- add stuff to the database release savepoint inner; rollback;
When the instructions inside the nested transaction complete successfully, it should make no difference if they are inside a savepoint demarcation or not.
Please have a look at the attached file nested_rollback.rst. It runs to completion here without error but illustrates the current problem. You can run it using
python -m doctest nested_rollback.rst
This seems to be related to issue