Skip to content

Commit

Permalink
kvserver: setup ranges in large unsplittable replicate test
Browse files Browse the repository at this point in the history
`TestLargeUnsplittableRangeReplicate` would fail when the SQL query to
show the table's replicas returned no results for the unsplittable range
being tested. No results would be returned when the table split was
delayed.

Update the test to insert a split at the first row, as well as the
existing split at the second row. This avoids the first range starting
with 5 replicas and the test's reliance on timely span config splits.

Resolves: #112774
Release note: None
  • Loading branch information
kvoli committed Oct 30, 2023
1 parent f2b7f9b commit ad54149
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pkg/kv/kvserver/replicate_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1774,8 +1774,6 @@ func TestLargeUnsplittableRangeReplicate(t *testing.T) {
base.TestClusterArgs{
ReplicationMode: base.ReplicationAuto,
ServerArgs: base.TestServerArgs{
ScanMinIdleTime: time.Millisecond,
ScanMaxIdleTime: time.Millisecond,
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
DefaultZoneConfigOverride: &zcfg,
Expand All @@ -1788,11 +1786,12 @@ func TestLargeUnsplittableRangeReplicate(t *testing.T) {

// We're going to create a table with many versions of a big row and a small
// row. We'll split the table in between the rows, to produce a large range
// and a small one. Then we'll increase the replication factor to 5 and check
// that both ranges behave the same - i.e. they both get up-replicated. For
// the purposes of this test we're only worried about the large one
// up-replicating, but we test the small one as a control so that we don't
// fool ourselves.
// and a small one. We'll also split the first row into its own range, to
// avoid the range inheriting 5 replicas from the system ranges. Then we'll
// increase the replication factor to 5 and check that both ranges behave the
// same - i.e. they both get up-replicated. For the purposes of this test
// we're only worried about the large one up-replicating, but we test the
// small one as a control so that we don't fool ourselves.

// Disable the queues so they don't mess with our manual relocation. We'll
// re-enable them later.
Expand All @@ -1805,6 +1804,8 @@ func TestLargeUnsplittableRangeReplicate(t *testing.T) {

_, err = db.Exec(`ALTER TABLE t EXPERIMENTAL_RELOCATE VALUES (ARRAY[1,2,3], 1)`)
require.NoError(t, err)
_, err = db.Exec(`ALTER TABLE t SPLIT AT VALUES (1)`)
require.NoError(t, err)
_, err = db.Exec(`ALTER TABLE t SPLIT AT VALUES (2)`)
require.NoError(t, err)

Expand Down Expand Up @@ -1862,7 +1863,7 @@ func TestLargeUnsplittableRangeReplicate(t *testing.T) {
testutils.SucceedsSoon(t, func() error {
forceProcess()
r := db.QueryRow(
"SELECT replicas FROM [SHOW RANGES FROM TABLE t] WHERE start_key LIKE '%TableMin%'")
"SELECT replicas FROM [SHOW RANGES FROM TABLE t] WHERE start_key LIKE '%/1'")
var repl string
if err := r.Scan(&repl); err != nil {
return err
Expand Down

0 comments on commit ad54149

Please sign in to comment.