From f084edf5e26967517ae67b5d1f8434e138fc3d83 Mon Sep 17 00:00:00 2001 From: Kiran Muddukrishna Date: Sat, 17 Oct 2026 14:53:00 +1100 Subject: [PATCH] executor: warm the parser before timing the lock-budget test ExecuteAcceptedBlocking parses before it waits; the first parse in a fresh process under -race took seconds and was counted against the test's 2s lock-wait bound, so the test failed when run alone. --- pkg/executor/accepted_blocking_integration_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/executor/accepted_blocking_integration_test.go b/pkg/executor/accepted_blocking_integration_test.go index 52dc9bab..95523a6c 100644 --- a/pkg/executor/accepted_blocking_integration_test.go +++ b/pkg/executor/accepted_blocking_integration_test.go @@ -42,9 +42,15 @@ func TestExecuteAcceptedBlockingLockBudgetExecutesNothing(t *testing.T) { _, err = holder.Exec(t.Context(), fmt.Sprintf("LOCK TABLE %s.t IN ACCESS EXCLUSIVE MODE", schema)) require.NoError(t, err) b := executor.BlockingBudget{LockTimeout: 100 * time.Millisecond, StatementTimeout: 5 * time.Second} + sql := fmt.Sprintf("DROP INDEX %s.i", schema) + // The executor parses the statement before it waits on anything, and the + // parser's first use in a process is slow, most of all under the race + // detector. Parse once here so the stopwatch times the lock wait, not + // that one-time setup. + mustParse(t, sql) start := time.Now() - _, err = executor.ExecuteAcceptedBlocking(t.Context(), pool, fmt.Sprintf("DROP INDEX %s.i", schema), pgx.Identifier{schema, "t"}, b) + _, err = executor.ExecuteAcceptedBlocking(t.Context(), pool, sql, pgx.Identifier{schema, "t"}, b) var budgetErr *executor.BudgetError require.ErrorAs(t, err, &budgetErr) assert.Equal(t, executor.CauseLock, budgetErr.Cause)