Commit 7b33aa8
Distribute lagging replicas across replica groups to reduce head-of-line blocking (#3259)
* Spread laggers across chunks in continuous replication to reduce head-of-line blocking
Adds an opt-in chunking mode for continuous replication that sorts replicas
within each per-remote-DataNode pass by remote lag (descending) and round-robin
distributes them into chunks of at most replicationMaxPartitionCountPerRequest,
instead of slicing sequentially via Utils.partitionList.
Today's sequential slicing can co-locate multiple ambient laggers in one chunk,
where the chunk's iteration time is gated by whichever member has the most data
to fetch — a head-of-line blocking effect. The spread mode guarantees that when
laggers <= chunk count, at most one lagger lands in any one chunk.
Gated by replication.spread.laggers.across.chunks, default false. When false,
behavior is byte-identical to today (delegates to Utils.partitionList). When
true, sorts via a snapshot-then-stride helper. Snapshot is required because
RemoteReplicaInfo.getRemoteLagFromLocalInBytes() reads non-volatile state
written by other threads; re-reading inside the sort comparator can trip
TimSort's contract check and kill the replication cycle.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Pass ReplicationConfig to DataNodeTracker; drop two primitive config params
Address review feedback: DataNodeTracker now takes ReplicationConfig directly
(matching ReplicaThread / ReplicationManager / ReplicationEngine /
BackupCheckerThread convention) instead of receiving primitive config-derived
values.
Drops two primitive ctor params: maxActiveGroupSize and spreadLaggersAcrossChunks.
DataNodeTracker reads them from replicationConfig.replicationMaxPartitionCountPerRequest
and replicationConfig.replicationSpreadLaggersAcrossChunks internally.
replicaThrottleDurationMs stays as a primitive: it's lane-specific (inter vs intra
DC), and ReplicaThread already resolves it at construction. Passing the resolved
value keeps lane logic where it belongs (in ReplicaThread) rather than duplicating
the lane branch inside DataNodeTracker.
Net: 8-param ctor → 7-param. Behavior unchanged; same fields read.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f6989d9 commit 7b33aa8
4 files changed
Lines changed: 371 additions & 9 deletions
File tree
- ambry-api/src/main/java/com/github/ambry/config
- ambry-replication/src
- main/java/com/github/ambry/replication
- continuous
- test/java/com/github/ambry/replication/continuous
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
| |||
407 | 418 | | |
408 | 419 | | |
409 | 420 | | |
| 421 | + | |
| 422 | + | |
410 | 423 | | |
411 | 424 | | |
412 | 425 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2318 | 2318 | | |
2319 | 2319 | | |
2320 | 2320 | | |
2321 | | - | |
2322 | | - | |
| 2321 | + | |
| 2322 | + | |
2323 | 2323 | | |
2324 | 2324 | | |
2325 | 2325 | | |
| |||
Lines changed: 60 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | | - | |
46 | 49 | | |
47 | 50 | | |
48 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
49 | 63 | | |
50 | | - | |
51 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
55 | 70 | | |
56 | 71 | | |
57 | | - | |
| 72 | + | |
58 | 73 | | |
59 | | - | |
60 | | - | |
| 74 | + | |
| 75 | + | |
61 | 76 | | |
62 | 77 | | |
63 | 78 | | |
| |||
147 | 162 | | |
148 | 163 | | |
149 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
150 | 203 | | |
0 commit comments