From 9b847caf8642448e9b22317d57904c326cda0fce Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Fri, 23 Dec 2022 11:36:23 +0000 Subject: [PATCH] roachtest: update `failover` tests to use `SHOW RANGES` This patch updates the `failover` roachtests to use the new `SHOW RANGES` syntax, because of the recent `crdb_internal.ranges` changes. Epic: none Release note: None --- pkg/cmd/roachtest/tests/failover.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/roachtest/tests/failover.go b/pkg/cmd/roachtest/tests/failover.go index efba31964b95..a9535238634a 100644 --- a/pkg/cmd/roachtest/tests/failover.go +++ b/pkg/cmd/roachtest/tests/failover.go @@ -706,14 +706,16 @@ func relocateRanges( where := fmt.Sprintf("(%s) AND %d = ANY(replicas)", predicate, source) for { require.NoError(t, conn.QueryRowContext(ctx, - `SELECT count(*) FROM crdb_internal.ranges WHERE `+where).Scan(&count)) + `SELECT count(distinct range_id) FROM [SHOW CLUSTER RANGES WITH TABLES] WHERE `+where). + Scan(&count)) if count == 0 { break } t.Status(fmt.Sprintf("moving %d ranges off of n%d (%s)", count, source, predicate)) for _, target := range to { _, err := conn.ExecContext(ctx, `ALTER RANGE RELOCATE FROM $1::int TO $2::int FOR `+ - `SELECT range_id FROM crdb_internal.ranges WHERE `+where, source, target) + `SELECT DISTINCT range_id FROM [SHOW CLUSTER RANGES WITH TABLES] WHERE `+where, + source, target) require.NoError(t, err) } time.Sleep(time.Second) @@ -729,13 +731,15 @@ func relocateLeases(t test.Test, ctx context.Context, conn *gosql.DB, predicate where := fmt.Sprintf("%s AND lease_holder != %d", predicate, to) for { require.NoError(t, conn.QueryRowContext(ctx, - `SELECT count(*) FROM crdb_internal.ranges WHERE `+where).Scan(&count)) + `SELECT count(distinct range_id) FROM [SHOW CLUSTER RANGES WITH TABLES, DETAILS] WHERE `+ + where). + Scan(&count)) if count == 0 { break } t.Status(fmt.Sprintf("moving %d leases to n%d (%s)", count, to, predicate)) _, err := conn.ExecContext(ctx, `ALTER RANGE RELOCATE LEASE TO $1::int FOR `+ - `SELECT range_id FROM crdb_internal.ranges WHERE `+where, to) + `SELECT DISTINCT range_id FROM [SHOW CLUSTER RANGES WITH TABLES, DETAILS] WHERE `+where, to) // When a node recovers, it may not have gossiped its store key yet. if err != nil && !strings.Contains(err.Error(), "KeyNotPresentError") { require.NoError(t, err)