the docs for
transaction/2is called inside another transaction, the function is simply executed, without wrapping the new transaction call in any way. If there is an error in the inner transaction and the error is rescued, or the inner transaction is rolled back, the whole outer transaction is marked as tainted, guaranteeing nothing will be committed.
However, the What’s new in Ecto ebook states that:
(…) The snippet above starts a transaction and then calls
transfer_money/3that also runs in a transaction. This works because Ecto converts nested transaction into savepoints. In case an inner transaction fails, it rolls back to its specific savepoint.
Which one is true?
It’s not clear to me what’s the behaviour of nested transactions, and what happens to the parent transaction when a nested one fails.