-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Cloud Spanner Client should prevent nested transactions #3476
Copy link
Copy link
Closed
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.release blockingRequired feature/issue must be fixed prior to next release.Required feature/issue must be fixed prior to next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the Spanner API.Issues related to the Spanner API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.release blockingRequired feature/issue must be fixed prior to next release.Required feature/issue must be fixed prior to next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Cloud Spanner does not support nested transactions. But the client library does allow users to call
database.run_in_transactioninside of the callback that is provided to an outerdatabase.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_transactioninside the callback provided todatabase.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.cc @jgeewax @bjwatson