Skip to content

Commit ac6110e

Browse files
wenyihu6tbg
authored andcommitted
asim: fix under-replication in rand testing
Previously, the simulator assumed that the LoadRangeInfo will include a range with min key as 0 (the first range created by initFirstRange relies on LoadRangeInfo to handle up-replication). When rand tests overrode this assumption, it led to under replication and failed assertion. This commit goes around this by setting defaultMinKey = 0 and disallowing the rand framework from overriding. We should fix the simulator assumption eventually. Epic: none Release note: none
1 parent 3f20923 commit ac6110e

File tree

8 files changed

+169
-1150
lines changed

8 files changed

+169
-1150
lines changed

pkg/kv/kvserver/asim/tests/default_settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const defaultKeyspace = 200000
2424
const (
2525
defaultRwRatio, defaultRate = 0.0, 0.0
2626
defaultMinBlock, defaultMaxBlock = 1, 1
27-
defaultMinKey, defaultMaxKey = int64(1), int64(defaultKeyspace)
27+
defaultMinKey, defaultMaxKey = int64(0), int64(defaultKeyspace)
2828
defaultSkewedAccess = false
2929
)
3030

pkg/kv/kvserver/asim/tests/rand_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,15 @@ func TestRandomized(t *testing.T) {
182182
scanIfExists(t, d, "rate", &staticOptionSettings.rate)
183183
scanIfExists(t, d, "min_block", &staticOptionSettings.minBlock)
184184
scanIfExists(t, d, "max_block", &staticOptionSettings.maxBlock)
185-
scanIfExists(t, d, "min_key", &staticOptionSettings.minKey)
185+
if hasMinKey := scanIfExists(t, d, "min_key", &staticOptionSettings.minKey); hasMinKey && staticOptionSettings.minKey != int64(0) {
186+
// TODO(wenyihu6): the simulator assumes the first range starts at 0.
187+
// If we allow ranges to be created with minKey > 0, we need to modify
188+
// initFirstRange() to properly up-replicate the first range.
189+
// Currently, it relies on LoadRangeInfo to properly up-replicate the
190+
// first range since that tells the simulator which stores to add
191+
// replicas to.
192+
panic("min_key is not supported for randomied testing")
193+
}
186194
scanIfExists(t, d, "max_key", &staticOptionSettings.maxKey)
187195
scanIfExists(t, d, "skewed_access", &staticOptionSettings.skewedAccess)
188196
scanIfExists(t, d, "ranges", &staticOptionSettings.ranges)

pkg/kv/kvserver/asim/tests/testdata/rand/default_settings

Lines changed: 49 additions & 418 deletions
Large diffs are not rendered by default.

pkg/kv/kvserver/asim/tests/testdata/rand/events

Lines changed: 9 additions & 154 deletions
Large diffs are not rendered by default.

pkg/kv/kvserver/asim/tests/testdata/rand/rand_cluster

Lines changed: 28 additions & 149 deletions
Large diffs are not rendered by default.

pkg/kv/kvserver/asim/tests/testdata/rand/rand_event

Lines changed: 18 additions & 89 deletions
Large diffs are not rendered by default.

pkg/kv/kvserver/asim/tests/testdata/rand/rand_ranges

Lines changed: 41 additions & 249 deletions
Large diffs are not rendered by default.

pkg/kv/kvserver/asim/tests/testdata/rand/weighted_rand

Lines changed: 14 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -20,69 +20,24 @@ generating cluster configurations using static option
2020
generating ranges configurations using randomized option
2121
placement_type=weighted_rand, range_gen_type=uniform, key_space=uniform, replication_factor=3, weightedRand=[0.1 0.2 0.7]
2222
generating load configurations using static option
23-
rw_ratio=0.00, rate=0.00, min_block=1, max_block=1, min_key=1, max_key=200000, skewed_access=false
23+
rw_ratio=0.00, rate=0.00, min_block=1, max_block=1, min_key=0, max_key=200000, skewed_access=false
2424
generating events configurations using static option
2525
generating settings configurations using static option
2626
----------------------------------
2727
sample1: start running
28-
configurations generated using seed 5571782338101878760
29-
basic cluster with nodes=1, stores_per_node=3
30-
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0.1 0.2 0.7], ranges=563, min_key=1, max_key=160411, replication_factor=3, bytes=0
31-
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=1, max_key=200000
32-
number of mutation events=0, number of assertion events=0
3328
initial state at 2022-03-21 11:00:00:
3429
stores(3)=[s1n1=(replicas(563)),s2n1=(replicas(563)),s3n1=(replicas(563))]
35-
topology:
36-
AU_EAST
37-
AU_EAST_1
38-
└── [1]
39-
no events were scheduled
40-
sample1: failed assertion
41-
conformance unavailable=0 under=0 over=0 violating=0 lease-violating=0 lease-less-preferred=0
42-
actual unavailable=1 under=1, over=0 violating=0 lease-violating=0 lease-less-preferred=0
43-
unavailable:
44-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3under replicated:
45-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3
30+
sample1: pass
4631
----------------------------------
4732
sample2: start running
48-
configurations generated using seed 4299969443970870044
49-
basic cluster with nodes=1, stores_per_node=3
50-
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0.1 0.2 0.7], ranges=299, min_key=1, max_key=9542, replication_factor=3, bytes=0
51-
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=1, max_key=200000
52-
number of mutation events=0, number of assertion events=0
5333
initial state at 2022-03-21 11:00:00:
5434
stores(3)=[s1n1=(replicas(299)),s2n1=(replicas(299)),s3n1=(replicas(299))]
55-
topology:
56-
AU_EAST
57-
AU_EAST_1
58-
└── [1]
59-
no events were scheduled
60-
sample2: failed assertion
61-
conformance unavailable=0 under=0 over=0 violating=0 lease-violating=0 lease-less-preferred=0
62-
actual unavailable=1 under=1, over=0 violating=0 lease-violating=0 lease-less-preferred=0
63-
unavailable:
64-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3under replicated:
65-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3
35+
sample2: pass
6636
----------------------------------
6737
sample3: start running
68-
configurations generated using seed 4157513341729910236
69-
basic cluster with nodes=1, stores_per_node=3
70-
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0.1 0.2 0.7], ranges=521, min_key=1, max_key=82660, replication_factor=3, bytes=0
71-
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=1, max_key=200000
72-
number of mutation events=0, number of assertion events=0
7338
initial state at 2022-03-21 11:00:00:
7439
stores(3)=[s1n1=(replicas(521)),s2n1=(replicas(521)),s3n1=(replicas(521))]
75-
topology:
76-
AU_EAST
77-
AU_EAST_1
78-
└── [1]
79-
no events were scheduled
80-
sample3: failed assertion
81-
conformance unavailable=0 under=0 over=0 violating=0 lease-violating=0 lease-less-preferred=0
82-
actual unavailable=1 under=1, over=0 violating=0 lease-violating=0 lease-less-preferred=0
83-
unavailable:
84-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3under replicated:
85-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3
40+
sample3: pass
8641
----------------------------------
8742

8843
clear
@@ -107,67 +62,37 @@ generating cluster configurations using static option
10762
generating ranges configurations using randomized option
10863
placement_type=weighted_rand, range_gen_type=uniform, key_space=uniform, replication_factor=3, weightedRand=[0 0 0 0.3 0.3 0.4]
10964
generating load configurations using static option
110-
rw_ratio=0.00, rate=0.00, min_block=1, max_block=1, min_key=1, max_key=200000, skewed_access=false
65+
rw_ratio=0.00, rate=0.00, min_block=1, max_block=1, min_key=0, max_key=200000, skewed_access=false
11166
generating events configurations using static option
11267
generating settings configurations using static option
11368
----------------------------------
11469
sample1: start running
11570
configurations generated using seed 5571782338101878760
11671
basic cluster with nodes=3, stores_per_node=2
117-
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0 0 0 0.3 0.3 0.4], ranges=563, min_key=1, max_key=160411, replication_factor=3, bytes=0
118-
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=1, max_key=200000
72+
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0 0 0 0.3 0.3 0.4], ranges=563, min_key=0, max_key=160411, replication_factor=3, bytes=0
73+
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
11974
number of mutation events=0, number of assertion events=0
12075
initial state at 2022-03-21 11:00:00:
12176
stores(6)=[s1n1=(replicas(22)),s2n1=(replicas(23)),s3n2=(replicas(23)),s4n2=(replicas(529)),s5n3=(replicas(563)),s6n3=(replicas(529))]
122-
topology:
123-
AU_EAST
124-
AU_EAST_1
125-
└── [1 2 3]
126-
no events were scheduled
127-
sample1: failed assertion
128-
conformance unavailable=0 under=0 over=0 violating=0 lease-violating=0 lease-less-preferred=0
129-
actual unavailable=1 under=1, over=0 violating=0 lease-violating=0 lease-less-preferred=0
130-
unavailable:
131-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3under replicated:
132-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3
77+
sample1: pass
13378
----------------------------------
13479
sample2: start running
13580
configurations generated using seed 4299969443970870044
13681
basic cluster with nodes=3, stores_per_node=2
137-
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0 0 0 0.3 0.3 0.4], ranges=299, min_key=1, max_key=9542, replication_factor=3, bytes=0
138-
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=1, max_key=200000
82+
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0 0 0 0.3 0.3 0.4], ranges=299, min_key=0, max_key=9542, replication_factor=3, bytes=0
83+
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
13984
number of mutation events=0, number of assertion events=0
14085
initial state at 2022-03-21 11:00:00:
14186
stores(6)=[s1n1=(replicas(53)),s2n1=(replicas(52)),s3n2=(replicas(52)),s4n2=(replicas(299)),s5n3=(replicas(142)),s6n3=(replicas(299))]
142-
topology:
143-
AU_EAST
144-
AU_EAST_1
145-
└── [1 2 3]
146-
no events were scheduled
147-
sample2: failed assertion
148-
conformance unavailable=0 under=0 over=0 violating=0 lease-violating=0 lease-less-preferred=0
149-
actual unavailable=1 under=1, over=0 violating=0 lease-violating=0 lease-less-preferred=0
150-
unavailable:
151-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3under replicated:
152-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3
87+
sample2: pass
15388
----------------------------------
15489
sample3: start running
15590
configurations generated using seed 4157513341729910236
15691
basic cluster with nodes=3, stores_per_node=2
157-
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0 0 0 0.3 0.3 0.4], ranges=521, min_key=1, max_key=82660, replication_factor=3, bytes=0
158-
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=1, max_key=200000
92+
weighted randomized ranges with placement_type=weighted_rand, weighted_rand=[0 0 0 0.3 0.3 0.4], ranges=521, min_key=0, max_key=82660, replication_factor=3, bytes=0
93+
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
15994
number of mutation events=0, number of assertion events=0
16095
initial state at 2022-03-21 11:00:00:
16196
stores(6)=[s1n1=(replicas(91)),s2n1=(replicas(91)),s3n2=(replicas(92)),s4n2=(replicas(521)),s5n3=(replicas(247)),s6n3=(replicas(521))]
162-
topology:
163-
AU_EAST
164-
AU_EAST_1
165-
└── [1 2 3]
166-
no events were scheduled
167-
sample3: failed assertion
168-
conformance unavailable=0 under=0 over=0 violating=0 lease-violating=0 lease-less-preferred=0
169-
actual unavailable=1 under=1, over=0 violating=0 lease-violating=0 lease-less-preferred=0
170-
unavailable:
171-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3under replicated:
172-
r1:000000000{0-1} [<no replicas>] applying ttl_seconds=0 num_voters=3
97+
sample3: pass
17398
----------------------------------

0 commit comments

Comments
 (0)