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

Commit 3c0df35

Browse files
committed
Address race condition
1 parent 7e79920 commit 3c0df35

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

google/cloud/spanner_v1/snapshot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ def _get_streamed_result_set(
616616
if self._transaction_id is None:
617617
is_inline_begin = True
618618
self._lock.acquire()
619+
if self._transaction_id is not None:
620+
is_inline_begin = False
621+
self._lock.release()
622+
request.transaction = TransactionSelector(id=self._transaction_id)
619623

620624
iterator = _restart_on_unavailable(
621625
method=method,

google/cloud/spanner_v1/transaction.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,9 @@ def execute_update(
497497
if self._transaction_id is None:
498498
is_inline_begin = True
499499
self._lock.acquire()
500+
if self._transaction_id is not None:
501+
is_inline_begin = False
502+
self._lock.release()
500503

501504
execute_sql_request = ExecuteSqlRequest(
502505
session=session.name,
@@ -651,6 +654,9 @@ def batch_update(
651654
if self._transaction_id is None:
652655
is_inline_begin = True
653656
self._lock.acquire()
657+
if self._transaction_id is not None:
658+
is_inline_begin = False
659+
self._lock.release()
654660

655661
execute_batch_dml_request = ExecuteBatchDmlRequest(
656662
session=session.name,

0 commit comments

Comments
 (0)