Skip to content

Commit 2606aec

Browse files
committed
chore(spanner): for mutations only case never do explicit begin before invoking transaction callable
1 parent caa7aa1 commit 2606aec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public void removeListener(Runnable listener) {
219219

220220
private CommitResponse commitResponse;
221221
private final Clock clock;
222+
private boolean mutationsOnly = false;
222223

223224
private final Map<SpannerRpc.Option, ?> channelHint;
224225

@@ -402,6 +403,7 @@ ApiFuture<CommitResponse> commitAsync() {
402403
synchronized (lock) {
403404
if (transactionIdFuture == null && transactionId == null && runningAsyncOperations == 0) {
404405
finishOps = SettableApiFuture.create();
406+
mutationsOnly = true;
405407
createTxnAsync(finishOps, randomMutation);
406408
} else {
407409
finishOps = finishedAsyncOperations;
@@ -1229,7 +1231,7 @@ private <T> T runInternal(final TransactionCallable<T> txCallable) {
12291231
if (attempt.get() > 0) {
12301232
// Do not inline the BeginTransaction during a retry if the initial attempt did not
12311233
// actually start a transaction.
1232-
useInlinedBegin = txn.transactionId != null;
1234+
useInlinedBegin = txn.mutationsOnly || txn.transactionId != null;
12331235

12341236
// Determine the latest transactionId when using a multiplexed session.
12351237
ByteString multiplexedSessionPreviousTransactionId = ByteString.EMPTY;

0 commit comments

Comments
 (0)