diff --git a/spanner/transaction.go b/spanner/transaction.go index 94fb770ead53..be6ee4af7228 100644 --- a/spanner/transaction.go +++ b/spanner/transaction.go @@ -1886,6 +1886,7 @@ func newReadWriteStmtBasedTransactionWithSessionHandle(ctx context.Context, c *C return err } + t.options = options t.txOpts = c.txo.merge(options) t.ct = c.ct t.otConfig = c.otConfig diff --git a/spanner/transaction_test.go b/spanner/transaction_test.go index c17d40879cbe..5617951a9696 100644 --- a/spanner/transaction_test.go +++ b/spanner/transaction_test.go @@ -888,11 +888,14 @@ func testReadWriteStmtBasedTransaction(t *testing.T, executionTimes map[string]S if attempts > 1 { tx, err = tx.ResetForRetry(ctx) } else { - tx, err = NewReadWriteStmtBasedTransaction(ctx, client) + tx, err = NewReadWriteStmtBasedTransactionWithOptions(ctx, client, TransactionOptions{TransactionTag: "test"}) } if err != nil { return 0, attempts, fmt.Errorf("failed to begin a transaction: %v", err) } + if g, w := tx.options.TransactionTag, "test"; g != w { + t.Errorf("transaction tag mismatch\n Got: %v\nWant: %v", g, w) + } rowCount, err = f(tx) if err != nil && status.Code(err) != codes.Aborted { tx.Rollback(ctx)