Commit 371b9f0
committed
ZOOKEEPER-2789: Reassign ZXID to a 24-bit epoch / 40-bit counter with rolling upgrade
Merge current master into the reassign_zxid branch and rework the change into an
opt-in, rolling-upgradeable wide-counter zxid layout.
The 32-bit counter overflowing forces a leader re-election roughly every 49.7
days at 1k writes/s (ZOOKEEPER-1277). This adds a 24-bit epoch / 40-bit counter
layout that pushes that to ~34.9 years while still allowing ~1915 years of
hourly elections before the epoch overflows.
- ZxidLayout / ZxidLayoutState: the legacy 32/32 and wide 24/40 layouts plus a
per-QuorumPeer record of the epoch from which the ensemble is wide. The static
ZxidUtils helpers remain the legacy-fixed layout for the on-the-wire epoch
carrier zxids of the handshake.
- Opt-in via zookeeper.wideCounterZxidEnabled (default off). A newly elected
leader switches at its new epoch, persists it to a new zxidLayoutSwitchEpoch
file, and announces it in the LEADERINFO handshake (learner protocol version
bumped to 0x11000). Learners below 0x11000 are refused once switched.
- The switch coincides with an epoch bump, so the numeric order of zxids is
preserved; layoutFor(zxid) selects the decode layout per zxid so existing
legacy snapshots/txnlogs are read correctly across the boundary without being
rewritten. One-way switch with an anti-downgrade guard.
- Replace hardcoded zxid bit operations with layout-aware calls across Leader,
LearnerHandler, Learner, Follower, ObserverMaster, ZKDatabase,
FastLeaderElection, Commands and LogChopper.1 parent 0cb298e commit 371b9f0
28 files changed
Lines changed: 1719 additions & 74 deletions
File tree
- zookeeper-server/src
- main/java/org/apache/zookeeper/server
- admin
- persistence
- quorum
- util
- test/java/org/apache/zookeeper
- server
- persistence
- quorum
- util
- test
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
88 | 96 | | |
89 | 97 | | |
90 | 98 | | |
| |||
332 | 340 | | |
333 | 341 | | |
334 | 342 | | |
335 | | - | |
| 343 | + | |
| 344 | + | |
336 | 345 | | |
337 | 346 | | |
338 | 347 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
1211 | 1212 | | |
1212 | 1213 | | |
1213 | 1214 | | |
1214 | | - | |
1215 | | - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1216 | 1218 | | |
1217 | 1219 | | |
1218 | 1220 | | |
| |||
Lines changed: 27 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
120 | 127 | | |
121 | 128 | | |
122 | 129 | | |
| |||
164 | 171 | | |
165 | 172 | | |
166 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
167 | 178 | | |
168 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
169 | 183 | | |
170 | 184 | | |
171 | 185 | | |
| |||
253 | 267 | | |
254 | 268 | | |
255 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
256 | 275 | | |
257 | 276 | | |
258 | | - | |
| 277 | + | |
259 | 278 | | |
260 | 279 | | |
261 | 280 | | |
| |||
457 | 476 | | |
458 | 477 | | |
459 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
460 | 483 | | |
461 | 484 | | |
| 485 | + | |
462 | 486 | | |
463 | 487 | | |
464 | 488 | | |
| |||
469 | 493 | | |
470 | 494 | | |
471 | 495 | | |
472 | | - | |
| 496 | + | |
473 | 497 | | |
474 | 498 | | |
475 | 499 | | |
| |||
479 | 503 | | |
480 | 504 | | |
481 | 505 | | |
482 | | - | |
| 506 | + | |
483 | 507 | | |
484 | 508 | | |
485 | 509 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
284 | 283 | | |
285 | 284 | | |
286 | 285 | | |
287 | | - | |
| 286 | + | |
288 | 287 | | |
289 | 288 | | |
290 | 289 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
Lines changed: 43 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
654 | 655 | | |
655 | 656 | | |
656 | 657 | | |
657 | | - | |
| 658 | + | |
658 | 659 | | |
659 | 660 | | |
660 | 661 | | |
661 | 662 | | |
662 | 663 | | |
663 | 664 | | |
664 | 665 | | |
665 | | - | |
| 666 | + | |
666 | 667 | | |
667 | 668 | | |
668 | 669 | | |
| |||
755 | 756 | | |
756 | 757 | | |
757 | 758 | | |
758 | | - | |
| 759 | + | |
759 | 760 | | |
760 | 761 | | |
761 | 762 | | |
| |||
1065 | 1066 | | |
1066 | 1067 | | |
1067 | 1068 | | |
1068 | | - | |
| 1069 | + | |
1069 | 1070 | | |
1070 | 1071 | | |
1071 | 1072 | | |
| |||
1274 | 1275 | | |
1275 | 1276 | | |
1276 | 1277 | | |
1277 | | - | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1278 | 1287 | | |
1279 | 1288 | | |
1280 | 1289 | | |
| |||
1298 | 1307 | | |
1299 | 1308 | | |
1300 | 1309 | | |
1301 | | - | |
1302 | | - | |
| 1310 | + | |
| 1311 | + | |
1303 | 1312 | | |
1304 | | - | |
1305 | | - | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
1306 | 1317 | | |
1307 | 1318 | | |
1308 | 1319 | | |
| |||
1480 | 1491 | | |
1481 | 1492 | | |
1482 | 1493 | | |
| 1494 | + | |
1483 | 1495 | | |
1484 | 1496 | | |
1485 | 1497 | | |
| |||
1501 | 1513 | | |
1502 | 1514 | | |
1503 | 1515 | | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
1504 | 1537 | | |
1505 | 1538 | | |
1506 | 1539 | | |
| |||
0 commit comments