Skip to content

Commit 550e2e1

Browse files
committed
chore: make precommit token check emulator-proof
1 parent ffa5c9e commit 550e2e1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.github/workflows/integration-tests-against-emulator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
services:
1212
emulator:
13-
image: gcr.io/cloud-spanner-emulator/emulator:1.5.37
13+
image: gcr.io/cloud-spanner-emulator/emulator
1414
ports:
1515
- 9010:9010
1616
- 9020:9020

google/cloud/spanner_v1/transaction.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,21 @@ def before_next_retry(nth_retry, delay_in_seconds):
328328
# successfully commit, and must be retried with the new precommit token.
329329
# The mutations should not be included in the new request, and no further
330330
# retries or exception handling should be performed.
331-
if commit_response_pb.precommit_token:
331+
if commit_response_pb._pb.HasField("precommit_token"):
332332
add_span_event(span, commit_retry_event_name)
333+
attempt = AtomicCounter(0)
334+
nth_request = database._next_nth_request
333335
commit_response_pb = api.commit(
334336
request=CommitRequest(
335337
precommit_token=commit_response_pb.precommit_token,
336338
**common_commit_request_args,
337339
),
338-
metadata=metadata,
340+
metadata=database.metadata_with_request_id(
341+
nth_request,
342+
attempt.value,
343+
metadata,
344+
span,
345+
),
339346
)
340347

341348
add_span_event(span, "Commit Done")

0 commit comments

Comments
 (0)