Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 68b9bc8

Browse files
author
Ilya Gurov
authored
docs: add auto retry mechanism explanation (#243)
1 parent 528a9b0 commit 68b9bc8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ Isolation level change example:
263263
eng = create_engine("spanner:///projects/project-id/instances/instance-id/databases/database-id")
264264
autocommit_engine = eng.execution_options(isolation_level="AUTOCOMMIT")
265265
266+
Automatic transactions retry
267+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268+
In the default ``SERIALIZABLE`` mode transactions may fail with ``Aborted`` exception. This is a transient kind of errors, which mostly happen to prevent data corruption by concurrent modifications. Though the original transaction becomes non operational, a simple retry of the queries solves the issue.
269+
270+
This, however, may require to manually repeat a long list of operations, executed in the failed transaction. To simplify it, Spanner Connection API tracks all the operations, executed inside current transaction, and their result checksums. If the transaction failed with ``Aborted`` exception, the Connection API will automatically start a new transaction and will re-run all the tracked operations, checking if their results are the same as they were in the original transaction. In case data changed, and results differ, the transaction is dropped, as there is no way to automatically retry it.
271+
272+
In ``AUTOCOMMIT`` mode automatic transactions retry mechanism is disabled, as every operation is committed just in time, and there is no way an ``Aborted`` exception can happen.
273+
266274
Autoincremented IDs
267275
~~~~~~~~~~~~~~~~~~~
268276

0 commit comments

Comments
 (0)