Commit 9e7b7f6
authored
Persist local_last_revision in storeLog even while shutting down (#1313)
Motivation:
- After a cluster reboot, a replica entered read-only mode while replaying the latest ZooKeeper log: the mirror PushAsIsCommand replayed at a revision whose effect was already in the local data, so it failed with a RedundantChangeException ("changes did not change anything ...").
- Root cause: ZooKeeperCommandExecutor.doStop() sets listenerInfo to null at the very beginning, before draining the in-flight blockingExecute via shutdown(executor). storeLog() persisted local_last_revision only when listenerInfo != null. When a command was being originated at shutdown time, its change had already been applied to local data and the ZooKeeper log node was still created, but the local_last_revision update was silently skipped. This left the local data ahead of both progress files (git HEAD at the new revision while last_revision and local_last_revision lagged by one).
- On the next start-up, replay re-executed that already-applied revision. Because the mirror command is an unnormalized PushAsIsCommand whose base revision is Revision.HEAD, re-applying it against the already-advanced head produced an empty diff and threw RedundantChangeException, tripping read-only mode. This was the gap introduced together with local_last_revision in #1303.
Modifications:
- Decouple the local_last_revision disk write from the listenerInfo guard in storeLog(): always call updateLocalLastAppliedRevision(revision), and gate only the in-memory ListenerInfo.localLastAppliedRevision update on listenerInfo.
Result:
- A command being originated while the replica is shutting down now durably records its progress in local_last_revision, so the data and the progress files stay consistent and the replica no longer re-applies an already-applied revision (and no longer enters read-only mode) on the next start-up.1 parent d4c2120 commit 9e7b7f6
2 files changed
Lines changed: 81 additions & 2 deletions
File tree
- server/src
- main/java/com/linecorp/centraldogma/server/internal/replication
- test/java/com/linecorp/centraldogma/server/internal/replication
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
379 | 380 | | |
380 | 381 | | |
381 | 382 | | |
| |||
1096 | 1097 | | |
1097 | 1098 | | |
1098 | 1099 | | |
1099 | | - | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
1100 | 1106 | | |
1101 | | - | |
1102 | 1107 | | |
1103 | 1108 | | |
1104 | 1109 | | |
| |||
Lines changed: 74 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
704 | 705 | | |
705 | 706 | | |
706 | 707 | | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
707 | 781 | | |
708 | 782 | | |
709 | 783 | | |
| |||
0 commit comments