Commit e5dd60b
authored
ZOOKEEPER-4925: Fix data loss due to propagation of discontinuous committedLog (#2254)
There are two variants of `ZooKeeperServer::processTxn`. Those two
variants diverge significantly since ZOOKEEPER-3484.
`processTxn(Request request)` pops outstanding change from
`outstandingChanges` and adds txn to `committedLog` for follower to sync
in addition to what `processTxn(TxnHeader hdr, Record txn)` does. The
`Learner` uses `processTxn(TxnHeader hdr, Record txn)` to commit txn to
memory after ZOOKEEPER-4394, which means it leaves `committedLog`
untouched in `SYNCHRONIZATION` phase.
This way, a stale follower will have hole in its `committedLog` after
joining cluster. The stale follower will propagate the in memory hole
to other stale nodes after becoming leader. This causes data loss.
The test case fails on master and 3.9.3, and passes on 3.9.2. So only
3.9.3 is affected.
This commit drops `processTxn(TxnHeader hdr, Record txn)` as
`processTxn(Request request)` is capable in `SYNCHRONIZATION` phase too.
Also, this commit rejects discontinuous proposals in `syncWithLeader`
and `committedLog`, so to avoid possible data loss.
Refs: ZOOKEEPER-4925, ZOOKEEPER-4394, ZOOKEEPER-3484
Reviewers: li4wang
Author: kezhuw
Closes #2254 from kezhuw/ZOOKEEPER-4925-fix-data-loss1 parent 524f1d7 commit e5dd60b
File tree
11 files changed
+196
-81
lines changed- zookeeper-server/src
- main/java/org/apache/zookeeper/server
- quorum
- test/java/org/apache/zookeeper/server
- quorum
11 files changed
+196
-81
lines changedLines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
Lines changed: 22 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
170 | 173 | | |
171 | 174 | | |
172 | 175 | | |
173 | | - | |
174 | | - | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
| 186 | + | |
| 187 | + | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
| |||
320 | 323 | | |
321 | 324 | | |
322 | 325 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | 326 | | |
328 | 327 | | |
329 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
330 | 342 | | |
331 | 343 | | |
332 | 344 | | |
333 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
334 | 350 | | |
335 | 351 | | |
336 | 352 | | |
| |||
Lines changed: 8 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1846 | 1846 | | |
1847 | 1847 | | |
1848 | 1848 | | |
1849 | | - | |
1850 | | - | |
1851 | | - | |
1852 | | - | |
1853 | | - | |
1854 | | - | |
1855 | | - | |
1856 | 1849 | | |
1857 | 1850 | | |
1858 | 1851 | | |
| |||
1864 | 1857 | | |
1865 | 1858 | | |
1866 | 1859 | | |
| 1860 | + | |
| 1861 | + | |
1867 | 1862 | | |
1868 | | - | |
| 1863 | + | |
1869 | 1864 | | |
1870 | 1865 | | |
1871 | 1866 | | |
| |||
1886 | 1881 | | |
1887 | 1882 | | |
1888 | 1883 | | |
| 1884 | + | |
1889 | 1885 | | |
1890 | | - | |
1891 | | - | |
1892 | | - | |
1893 | | - | |
1894 | | - | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
1895 | 1889 | | |
| 1890 | + | |
1896 | 1891 | | |
1897 | 1892 | | |
1898 | 1893 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
164 | 163 | | |
165 | 164 | | |
166 | 165 | | |
167 | | - | |
168 | 166 | | |
169 | 167 | | |
170 | 168 | | |
| |||
179 | 177 | | |
180 | 178 | | |
181 | 179 | | |
182 | | - | |
| 180 | + | |
183 | 181 | | |
184 | 182 | | |
185 | 183 | | |
| |||
Lines changed: 6 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | | - | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
| |||
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
82 | | - | |
83 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 87 | + | |
92 | 88 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 89 | + | |
96 | 90 | | |
97 | 91 | | |
98 | 92 | | |
| |||
188 | 182 | | |
189 | 183 | | |
190 | 184 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | 185 | | |
Lines changed: 36 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
| |||
535 | 539 | | |
536 | 540 | | |
537 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
538 | 563 | | |
539 | 564 | | |
540 | 565 | | |
| |||
609 | 634 | | |
610 | 635 | | |
611 | 636 | | |
| 637 | + | |
| 638 | + | |
612 | 639 | | |
613 | 640 | | |
614 | 641 | | |
| |||
630 | 657 | | |
631 | 658 | | |
632 | 659 | | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
| 660 | + | |
640 | 661 | | |
641 | 662 | | |
642 | 663 | | |
| |||
666 | 687 | | |
667 | 688 | | |
668 | 689 | | |
669 | | - | |
| 690 | + | |
670 | 691 | | |
671 | 692 | | |
672 | 693 | | |
| |||
696 | 717 | | |
697 | 718 | | |
698 | 719 | | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
| 720 | + | |
707 | 721 | | |
708 | 722 | | |
709 | 723 | | |
710 | | - | |
| 724 | + | |
711 | 725 | | |
712 | 726 | | |
713 | 727 | | |
| |||
780 | 794 | | |
781 | 795 | | |
782 | 796 | | |
783 | | - | |
784 | | - | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
785 | 800 | | |
786 | 801 | | |
787 | 802 | | |
| |||
823 | 838 | | |
824 | 839 | | |
825 | 840 | | |
826 | | - | |
| 841 | + | |
827 | 842 | | |
828 | 843 | | |
829 | 844 | | |
| |||
847 | 862 | | |
848 | 863 | | |
849 | 864 | | |
850 | | - | |
851 | | - | |
| 865 | + | |
852 | 866 | | |
853 | 867 | | |
854 | 868 | | |
| |||
Lines changed: 2 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 205 | + | |
209 | 206 | | |
210 | | - | |
211 | 207 | | |
212 | 208 | | |
213 | 209 | | |
| |||
219 | 215 | | |
220 | 216 | | |
221 | 217 | | |
222 | | - | |
223 | 218 | | |
224 | | - | |
225 | 219 | | |
226 | 220 | | |
227 | | - | |
228 | | - | |
| 221 | + | |
229 | 222 | | |
230 | 223 | | |
231 | 224 | | |
| |||
0 commit comments