Skip to content

Commit

Permalink
sql/tests: deflake TestErrorDuringExtendedProtocolCommit
Browse files Browse the repository at this point in the history
This fixes a race condition with how the error gets injected.

Release note: None
  • Loading branch information
rafiss committed Apr 24, 2023
1 parent a2f31ca commit 3fda043
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sql/tests/autocommit_extended_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down

0 comments on commit 3fda043

Please sign in to comment.