From 5581be691456d70ca8b45f9f85321b1a9a671a4a Mon Sep 17 00:00:00 2001 From: Yong-Han Chen Date: Fri, 28 Nov 2025 22:30:26 -0600 Subject: [PATCH] test: fix `TestTransactionTimeoutSecondStatement` by increasing timeout Problem: The test is flaky in CI because the local transaction_timeout(20ms) is too tight to complete the update operation, leading to a `context deadline exceeded` error or `spanner: code = "DeadlineExceeded"...` error. Solution: By running the test 10,000 times with the -race flag, I found that only setting transaction_timeout to at least 1s passees 10,000 times. I have experimented with 0.06s, 0.2s, and 0.5s. However, all of them (0.06s, 0.2s, and 0.5s) fail before passing 10,000 times. Signed-off-by: Yong-Han Chen --- transaction_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transaction_test.go b/transaction_test.go index ddd6d05a..5ee4bc3e 100644 --- a/transaction_test.go +++ b/transaction_test.go @@ -323,14 +323,14 @@ func TestTransactionTimeoutSecondStatement(t *testing.T) { ctx := context.Background() tx, _ := db.BeginTx(ctx, &sql.TxOptions{}) - if _, err := tx.ExecContext(ctx, "set local transaction_timeout=20ms"); err != nil { + if _, err := tx.ExecContext(ctx, "set local transaction_timeout=1000ms"); err != nil { t.Fatal(err) } if _, err := tx.ExecContext(ctx, testutil.UpdateBarSetFoo); err != nil { t.Fatal(err) } - server.TestSpanner.PutExecutionTime(testutil.MethodExecuteStreamingSql, testutil.SimulatedExecutionTime{MinimumExecutionTime: 50 * time.Millisecond}) + server.TestSpanner.PutExecutionTime(testutil.MethodExecuteStreamingSql, testutil.SimulatedExecutionTime{MinimumExecutionTime: 1500 * time.Millisecond}) rows, err := tx.QueryContext(ctx, testutil.SelectFooFromBar, ExecOptions{DirectExecuteQuery: true}) if rows != nil { _ = rows.Close()