Skip to content

Commit 7e006d5

Browse files
tbgsumeerbhola
authored andcommitted
mmaprototype: add overview comment to a few new test cases
1 parent 52ad18b commit 7e006d5

File tree

3 files changed

+64
-5
lines changed

3 files changed

+64
-5
lines changed

pkg/kv/kvserver/allocator/mmaprototype/testdata/cluster_state/rebalance_replica

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# Tests rebalancing a replica from a local store to a remote store (stores on
2+
# different nodes).
3+
#
4+
# Scenario: Store s1 on node 1 initially holds the replica and lease for range 1.
5+
# The test rebalances the replica (and lease) from s1 to s2 on node 2.
6+
#
7+
# Steps and expectations:
8+
# 1. Creates pending changes for the rebalance, verifying load adjustments
9+
# immediately reflect the pending state.
10+
# 2. Simulates enactment: when s1's leaseholder message arrives without the
11+
# range (indicating s1 no longer has the lease), both changes are considered
12+
# enacted simultaneously. The range state is removed since the lease moved to
13+
# a non-local store.
14+
# 3. Tracks load adjustments: pending changes adjust load until store-reported
15+
# load reflects the change (after >10s of enactment). Load messages arriving
16+
# too early (<10s after enactment) result in incorrect adjusted loads (negative
17+
# for s1, inflated for s2) until later load messages arrive.
18+
# 4. Verifies changes are removed from load tracking once store-reported load
19+
# reflects the change.
120
set-store
221
store-id=1 node-id=1 attrs=purple locality-tiers=region=us-west-1,zone=us-west-1a
322
store-id=2 node-id=2 attrs=yellow locality-tiers=region=us-east-1,zone=us-east-1a
@@ -125,9 +144,9 @@ store-load-msg
125144
store-id=1 node-id=2 load=[5,5,5] capacity=[100,100,100] secondary-load=1 load-time=14s
126145
----
127146

128-
# Neither load is recent enough to be considered as accounting for the enacted
129-
# changes. So s2 adjusted load appears very high and s1 adjusted load becomes
130-
# negative.
147+
# Neither load is recent enough (computePendingChangesReflectedInLatestLoad
148+
# timeout) to be considered as accounting for the enacted changes. So s2
149+
# adjusted load appears very high and s1 adjusted load becomes negative.
131150
get-load-info
132151
----
133152
store-id=1 node-id=1 reported=[cpu:5, write-bandwidth:5, byte-size:5] adjusted=[cpu:-75, write-bandwidth:-75, byte-size:-75] node-reported-cpu=80 node-adjusted-cpu=-80 seq=6

pkg/kv/kvserver/allocator/mmaprototype/testdata/cluster_state/rebalance_replica_local_stores

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# Tests rebalancing a replica between two local stores (stores on the same node).
2+
#
3+
# Scenario: Two stores (s1, s2) on node 1. Initially, s1 holds the replica and
4+
# lease for range 1. The test rebalances the replica (and lease) from s1 to s2,
5+
# then back from s2 to s1.
6+
#
7+
# Steps and expectations:
8+
# 1. Creates pending changes for the rebalance, verifying load adjustments
9+
# immediately reflect the pending state.
10+
# 2. Simulates enactment: when s2's leaseholder message arrives showing it has
11+
# the lease, change 1 (add to s2) is marked enacted. Change 2 (remove from
12+
# s1) remains pending until s1 is removed from the replica set.
13+
# 3. Verifies enacted changes cannot be rejected (they're removed from
14+
# pendingChanges).
15+
# 4. Verifies no-rollback changes cannot be rejected once any change in the
16+
# set is enacted.
17+
# 5. Tracks load adjustments: pending changes adjust load until store-reported
18+
# load reflects the change (after 10s of enactment). After that, the change
19+
# is removed from load tracking but may remain for GC.
20+
# 6. Tests GC: changes marked no-rollback cannot be GC'd via normal GC (which
21+
# requires undo). They're only removed once store-reported load reflects the
22+
# change.
23+
# 7. Rebalances back from s2 to s1 and verifies changes are GC'd after the
24+
# normal GC duration.
25+
#
126
# Two stores on the same node.
227
set-store
328
store-id=1 node-id=1 attrs=purple locality-tiers=region=us-west-1,zone=us-west-1a

pkg/kv/kvserver/allocator/mmaprototype/testdata/cluster_state/rebalance_replica_local_stores_enacted_gc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
# Two stores on the same node.
1+
# Tests GC of partially enacted changes when rebalancing between local stores.
2+
# This is a variation of rebalance_replica_local_stores in which a rebalancing
3+
# operation is partially enacted but the remainder is ultimately garbage collected.
4+
#
5+
# - The range initially initially sits on (n1s1,n3s3), and is then rebalanced to
6+
# (n1s2,n3s4), i.e. moved between n1's two stores.
7+
# - The second half of the pending change (removal of s1) never gets enacted.
8+
# - That change is pending is no-rollback due to the first half having been enacted.
9+
# After 30s (partiallyEnactedGCDuration) has elapsed since the partial
10+
# enactment, the removal is GC'd with the next leaseholder message. In
11+
# particular, this change does not have to wait for the much longer regular GC
12+
# timeout.
13+
# - A second rebalance is carried out on the same range, while an enacted remnant
14+
# of the first operation remains.
215
set-store
316
store-id=1 node-id=1 attrs=purple locality-tiers=region=us-west-1,zone=us-west-1a
417
store-id=2 node-id=1 attrs=yellow locality-tiers=region=us-east-1,zone=us-east-1a
@@ -109,7 +122,9 @@ change-id=2 store-id=1 node-id=1 range-id=1 load-delta=[cpu:-2, write-bandwidth:
109122
prev=(replica-id=1 type=VOTER_FULL leaseholder=true)
110123
next=(replica-id=none type=VOTER_FULL)
111124

112-
# Same store leaseholder msg from s2. The pending change for s1 is gc'd.
125+
# Same store leaseholder msg from s2. The pending change for s1 is gc'd because
126+
# the more aggressive partiallyEnactedGCDuration (30s) applies. It is immaterial
127+
# that the message originates from s2 and not s1.
113128
store-leaseholder-msg
114129
store-id=2
115130
range-id=1 load=[3,3,3] raft-cpu=2 config=(num_replicas=3 constraints={'+region=us-west-1:1'} voter_constraints={'+region=us-west-1:1'})

0 commit comments

Comments
 (0)