Skip to content

Commit

Permalink
roachtest: add an early check in cluster-init
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
tbg committed May 13, 2019
1 parent 9bf7dbe commit 444c28e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1940,11 +1940,15 @@ func (m *monitor) wait(args ...string) error {
}

func waitForFullReplication(t *test, db *gosql.DB) {
tStart := timeutil.Now()
for ok := false; !ok; time.Sleep(time.Second) {
if err := db.QueryRow(
"SELECT min(array_length(replicas, 1)) >= 3 FROM crdb_internal.ranges",
).Scan(&ok); err != nil {
t.Fatal(err)
}
if timeutil.Since(tStart) > 30*time.Second {
t.l.Printf("still waiting for full replication")
}
}
}
7 changes: 7 additions & 0 deletions pkg/cmd/roachtest/cluster_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ func runClusterInit(ctx context.Context, t *test, c *cluster) {

addrs := c.InternalAddr(ctx, c.All())

// TODO(tbg): this should never happen, but I saw it locally. The result
// is the test hanging forever, because all nodes will create their own
// single node cluster and waitForFullReplication never returns.
if addrs[0] == "" {
t.Fatal("no address for first node")
}

// Legacy-style init where we start node 1 without a join flag and then point
// the other nodes at it.
func() {
Expand Down

0 comments on commit 444c28e

Please sign in to comment.