Skip to content

Commit

Permalink
Merge #62411
Browse files Browse the repository at this point in the history
62411: roachtest: wait for range split in follower-reads test r=nvanbenschoten a=nvanbenschoten

Fixes #62240.
Fixes #62196.
Fixes #62067.
Fixes #62065.

Range splits after a table creation are async, so don't expect one immediately.

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Mar 23, 2021
2 parents 8ef4f67 + 1a417c9 commit 3f9f18e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pkg/cmd/roachtest/follower_reads.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/ts/tspb"
"github.com/cockroachdb/cockroach/pkg/util/httputil"
"github.com/cockroachdb/cockroach/pkg/util/retry"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/errors"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -162,8 +163,7 @@ func runFollowerReadsTest(

// Wait until the table has completed up-replication.
t.l.Printf("waiting for up-replication...")
tStart := timeutil.Now()
for {
require.NoError(t, retry.ForDuration(5*time.Minute, func() error {
const q = `
SELECT
coalesce(array_length(voting_replicas, 1), 0),
Expand All @@ -173,7 +173,10 @@ func runFollowerReadsTest(
WHERE
table_name = 'test'`
var voters, nonVoters int
require.NoError(t, db.QueryRowContext(ctx, q).Scan(&voters, &nonVoters))
if err := db.QueryRowContext(ctx, q).Scan(&voters, &nonVoters); err != nil {
t.l.Printf("retrying: %v\n", err)
return err
}

var ok bool
if survival == zone {
Expand All @@ -183,15 +186,11 @@ func runFollowerReadsTest(
// Expect 5 voting replicas and 0 non-voting replicas.
ok = voters == 5 && nonVoters == 0
}
if ok {
break
}

if timeutil.Since(tStart) > 30*time.Second {
t.l.Printf("still waiting for full replication")
if !ok {
return errors.Newf("rebalancing not complete")
}
time.Sleep(time.Second)
}
return nil
}))

const rows = 100
const concurrency = 32
Expand Down

0 comments on commit 3f9f18e

Please sign in to comment.