-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Cloud Spanner does not support nested transactions. But the client library does allow users to call database.run_in_transaction
inside of the callback that is provided to an outer database.run_in_transaction
. This is misleading since users might believe that this will behave like a nested transaction but in reality these will be two independent transactions. This is confusing and a source of bugs. Specifically the inner transaction might succeed while the outer might ABORT, in which case the callback will be rerun thus rerunning the inner transaction.
We should prevent this from happening by detecting and raising an error if someone calls database.run_in_transaction
inside the callback provided to database.run_in_transaction
. Note that this needs to be done before Beta since this is a known breaking change.
Also note that if we come across a use case where we do want to allow calling a nested database.run_in_transaction
, we should be able to enable that in future without making a breaking change.