Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
128857: changefeedccl: attempt to deflake distribution strategy unit tests r=rharding6373 a=andyyang890

This patch attempts to deflake the changefeed distribution strategy
unit tests by replacing all the manually constructed
`ALTER TABLE ... RELOCATE` statements with a single statement that
uses a select query.

Informs cockroachdb#125170
Informs cockroachdb#125231
Informs cockroachdb#127027
Informs cockroachdb#127313

Release note: None

Co-authored-by: Andy Yang <[email protected]>
  • Loading branch information
craig[bot] and andyyang890 committed Aug 13, 2024
2 parents 5dbc891 + fbda8dc commit a8b016c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions pkg/ccl/changefeedccl/changefeed_dist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,20 +423,12 @@ func newRangeDistributionTester(
t.Logf("%s: spitting the table took %s", timeutil.Now().Format(time.DateTime), timeutil.Since(start))

// Distribute the leases exponentially across the first 5 nodes.
for i := 0; i < 64; i += 1 {
nodeID := 1
// Avoid log(0).
if i != 0 {
nodeID = int(math.Floor(math.Log2(float64(i)))) + 1
}
t.Logf("%s: relocating range for %d to store %d", timeutil.Now().Format(time.DateTime), i, nodeID)
cmd := fmt.Sprintf(`ALTER TABLE x EXPERIMENTAL_RELOCATE VALUES (ARRAY[%d], %d)`, nodeID, i)
// Relocate can fail with errors like `change replicas... descriptor changed` thus the SucceedsSoon.
start := timeutil.Now()
sqlDB.ExecSucceedsSoon(t, cmd)
t.Logf("%s: relocating range for %d to store %d took %s",
timeutil.Now().Format(time.DateTime), i, nodeID, timeutil.Since(start))
}
t.Logf("%s: relocating ranges in exponential distribution", timeutil.Now().Format(time.DateTime))
start = timeutil.Now()
// Relocate can fail with errors like `change replicas... descriptor changed` thus the SucceedsSoon.
sqlDB.ExecSucceedsSoon(t,
`ALTER TABLE x RELOCATE SELECT ARRAY[floor(log(greatest(1,id)::DECIMAL)/log(2::DECIMAL))::INT+1], id FROM x`)
t.Logf("%s: relocating ranges took %s", timeutil.Now().Format(time.DateTime), timeutil.Since(start))

return &rangeDistributionTester{
ctx: ctx,
Expand Down

0 comments on commit a8b016c

Please sign in to comment.