Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachtest: wait for range split in follower-reads test #62411

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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