Skip to content

Commit

Permalink
roachtest: use context timeout to bound descriptor validation check
Browse files Browse the repository at this point in the history
Previously, the CheckInvalidDescriptors utility would set the crdb
`statement_timeout` session variable to 1 minute, which would inadvertently
cause subsequent long running queries to fail. This patch runs the validation
check with a context timeout instead.

Fixes #115852
Fixes #115956
Fixes #115862

Release note: none
  • Loading branch information
msbutler committed Dec 11, 2023
1 parent a23306b commit 2c685f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/cmd/roachtest/roachtestutil/validation_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package roachtestutil
import (
"context"
gosql "database/sql"
"time"

"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
Expand Down Expand Up @@ -69,8 +70,9 @@ func CheckInvalidDescriptors(ctx context.Context, db *gosql.DB) error {
// query will take a lease on the database sqlDB is connected to and only run
// the query on the given database. The "" prefix prevents this lease
// acquisition and allows the query to fetch all descriptors in the cluster.
rows, err := db.QueryContext(ctx, `
SET statement_timeout = '1m';
validationContext, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
rows, err := db.QueryContext(validationContext, `
SELECT id, obj_name, error FROM "".crdb_internal.invalid_objects`)
if err != nil {
return err
Expand Down

0 comments on commit 2c685f0

Please sign in to comment.