-
Notifications
You must be signed in to change notification settings - Fork 473
Description
In the Build a Python app with SQLAlchemy docs we say re: the run_transaction()
wrapper method that:
It will run your transactions to completion much faster than a naive implementation that created a fresh transaction after every retry error. Because of the way the CockroachDB dialect's driver structures the transaction attempts (using a
SAVEPOINT
statement under the hood, which has a slightly different meaning in CockroachDB than in some other databases), the server is able to preserve some information about the previously attempted transactions to allow subsequent retries to complete more easily.
This is not actually correct. Using an application-level retry loop that does not use SAVEPOINT
is basically fine most of the time, and performs well if you add exponential backoff.
For context see the discussion in this mailing list thread, and also cockroachdb/cockroach#5935