From 3fda043cdb79e0272c2ae7c7c3102711735c90e0 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Mon, 24 Apr 2023 16:37:41 -0400 Subject: [PATCH] sql/tests: deflake TestErrorDuringExtendedProtocolCommit This fixes a race condition with how the error gets injected. Release note: None --- pkg/sql/tests/autocommit_extended_protocol_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sql/tests/autocommit_extended_protocol_test.go b/pkg/sql/tests/autocommit_extended_protocol_test.go index 55f672bce9e7..066aab7a04ff 100644 --- a/pkg/sql/tests/autocommit_extended_protocol_test.go +++ b/pkg/sql/tests/autocommit_extended_protocol_test.go @@ -170,12 +170,12 @@ func TestErrorDuringExtendedProtocolCommit(t *testing.T) { }, BeforeAutoCommit: func(ctx context.Context, stmt string) error { if shouldErrorOnAutoCommit.Get() { - shouldErrorOnAutoCommit.Set(false) // Only inject the error if we're in the same trace as the one we // saw when executing our test query. This is so we know that this // autocommit corresponds to our test qyery rather than an internal // query. if traceID == tracing.SpanFromContext(ctx).TraceID() { + shouldErrorOnAutoCommit.Set(false) return errors.New("injected error") } }