From cb9acebb81358465b61217a3510e7ee3e93a9338 Mon Sep 17 00:00:00 2001 From: skuruppu Date: Fri, 8 May 2026 01:54:20 +0000 Subject: [PATCH] chore(spanner): add missing commit ts logging If the commit timestamp is missing from a commit response, it would be good to have more visibility into the state of the commit by looking at whether it's in the commit-retry phase or not. --- .../cloud/spanner/TransactionRunnerImpl.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java b/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java index b2615f240526..55f7197a9220 100644 --- a/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java +++ b/java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java @@ -527,8 +527,25 @@ public void run() { return; } if (!proto.hasCommitTimestamp()) { + if (proto.hasPrecommitToken() && retryAttemptDueToCommitProtocolExtension) { + txnLogger.log( + Level.FINE, + "Missing commitTimestamp, response has precommit token " + + "and client has already attempted commit retry"); + span.addAnnotation( + "Missing commitTimestamp, response has precommit token " + + "and client has already attempted commit retry"); + } else if (!proto.hasPrecommitToken()) { + txnLogger.log( + Level.FINE, "Missing commitTimestamp, response has no precommit token"); + span.addAnnotation( + "Missing commitTimestamp, " + "response has no precommit token"); + } throw newSpannerException( - ErrorCode.INTERNAL, "Missing commitTimestamp:\n" + session.getName()); + ErrorCode.INTERNAL, "Missing commitTimestamp:\n" + session.getName() + + "\nHas precommit token: " + proto.hasPrecommitToken() + + "\nAlready attempted commit retry: " + + retryAttemptDueToCommitProtocolExtension); } span.addAnnotation("Commit Done"); opSpan.end();