Cloud Spanner Client should prevent nested transactions #528
Labels
api: spanner
Issues related to the Spanner API.
priority: p1
Important issue which blocks shipping the next release. Will be fixed prior to next release.
Cloud Spanner does not support nested transactions. But the client library does allow users to call
Database.runTransaction
inside of the callback that is provided to an outerDatabase.runTransaction
. 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.runTransaction
inside the callback provided toDatabase.runTransaction
. 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 runTransaction, we should be able to enable that in future without making a breaking change.
cc @jgeewax @bjwatson
The text was updated successfully, but these errors were encountered: