Skip to content

Commit 54c0d0f

Browse files
fix(spanner): only set snapshot isolation read timestamp for SI or optimistic txns in CloudClientExecutor (#14346)
In `CloudClientExecutor`, `CommitResponse.getSnapshotTimestamp()` was unconditionally populated into `SpannerActionOutcome`'s `snapshot_isolation_txn_read_timestamp` for all committing read-write transactions. When a standard Serializable Pessimistic transaction executes over a multiplexed session with reads, Cloud Spanner SpanFE records an internal snapshot timestamp and includes it in CommitResponse. Setting snapshot_isolation_txn_read_timestamp for non-SI/non-optimistic transactions violates systest SpotValidator invariants, causing validation failures with: `"Snapshot read timestamp set in a txn that's not a snapshot isolation or optimistic txn."` This change gates setting `snapshot_isolation_txn_read_timestamp` on (`rwTxn.repeatableRead || rwTxn.optimistic`), ensuring the field is only populated when the transaction actually ran with snapshot isolation or optimistic concurrency control.
1 parent d76d159 commit 54c0d0f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎java-spanner/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ public synchronized Status finish(Mode finishMode, OutcomeSender sender) {
788788
if (finishMode == Mode.COMMIT && rwTxn.runner.getCommitResponse() != null) {
789789
com.google.cloud.spanner.CommitResponse commitResponse =
790790
rwTxn.runner.getCommitResponse();
791-
if (commitResponse.getSnapshotTimestamp() != null) {
791+
if ((rwTxn.repeatableRead || rwTxn.optimistic)
792+
&& commitResponse.getSnapshotTimestamp() != null) {
792793
outcomeBuilder.setSnapshotIsolationTxnReadTimestamp(
793794
Timestamps.toMicros(commitResponse.getSnapshotTimestamp().toProto()));
794795
}

0 commit comments

Comments
 (0)