From 1a4f4fd675a1580c87ad1d53c650a20bd2ff4811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Tue, 14 Jul 2020 05:09:26 +0200 Subject: [PATCH] fix: fix potential unnecessary transaction retry (#337) A transaction could in some circumstances be retried after an abort using the previous transaction id. This would cause the retry to abort directly as well, and then start a new transaction. This extra loop has now been removed. Fixes #327 --- .../java/com/google/cloud/spanner/TransactionRunnerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java index c10b713285..21812aa96a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java @@ -654,7 +654,7 @@ private T runInternal(final TransactionCallable txCallable) { new Callable() { @Override public T call() { - if (txn.isAborted()) { + if (attempt.get() > 0) { txn = session.newTransaction(); } checkState(