Commit 2ec279a
Fix maintenance state related transitions. (#786)
* Fix maintenance state related transitions.
We used to disallow starting maintenance on a node in some cases, but it
seems that the user should be able to decide about when they need to operate
maintenance on their own nodes. After all, we don't stop Postgres when going
to maintenance, so users may change their mind without impacting their
service. A WARNING message is now displayed in some cases that were
previously prevented.
Also, the transition from WAIT_MAINTENANCE to MAINTENANCE was failing since
we improved the Group State Machine for the primary node, which would go
from JOIN_PRIMARY to PRIMARY without waiting for the other nodes to reach
their assigned state of WAIT_MAINTENANCE.
* Prevent WAIT_PRIMARY state when all secondaries are in maintenance.
If number-sync-standbys is set to 1 or more, then we still allow all the
secondary nodes to be put in maintenance mode, and we maintain the primary
node in the PRIMARY state, in a way that writes are going to be blocked on
the primary.
* Refrain from DRAINING state when there is no candidate.
When a primary is not healthy and there is no candidate node to failover to,
then assigning to the primary the DRAINING state is not helping.
Also, the reason why we don't have a candidate at the moment might be that
the other nodes are in MAINTENANCE and the operator is restarting Postgres
to install some new configuration.
* Consider wait_maintenance a maintanance state in the monitor
* Allow disabling maintenance in prepare_maintenance state
* In maintenance, setup Postgres as a standby node without a primary.
The primary election might not be finished yet, and also if the operator is to
restart the local instance, they probably don't want it to connect to any other
node in the system during the maintenance window.
* Allow the transition from prepare_maintenance to maintenance to happen
early on a multiple standby system, at soon as an election is triggered.
* Per review, allow prepare_maintenance -> catchingup transition.
* Check for the right node to reach reported state
Co-authored-by: Jelte Fennema <github-tech@jeltef.nl>1 parent 329b554 commit 2ec279a
11 files changed
Lines changed: 475 additions & 253 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| 556 | + | |
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
559 | 560 | | |
560 | 561 | | |
561 | 562 | | |
562 | | - | |
| 563 | + | |
| 564 | + | |
563 | 565 | | |
564 | | - | |
| 566 | + | |
565 | 567 | | |
566 | 568 | | |
567 | 569 | | |
| |||
651 | 653 | | |
652 | 654 | | |
653 | 655 | | |
| 656 | + | |
| 657 | + | |
654 | 658 | | |
655 | 659 | | |
656 | 660 | | |
657 | 661 | | |
658 | 662 | | |
659 | 663 | | |
660 | | - | |
| 664 | + | |
| 665 | + | |
661 | 666 | | |
662 | | - | |
| 667 | + | |
663 | 668 | | |
664 | 669 | | |
665 | 670 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| 345 | + | |
345 | 346 | | |
346 | 347 | | |
347 | 348 | | |
| |||
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
365 | 369 | | |
366 | 370 | | |
367 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
| 723 | + | |
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
| |||
737 | 737 | | |
738 | 738 | | |
739 | 739 | | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | 740 | | |
749 | 741 | | |
750 | | - | |
| 742 | + | |
751 | 743 | | |
752 | 744 | | |
753 | 745 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
4092 | 4093 | | |
4093 | 4094 | | |
4094 | 4095 | | |
4095 | | - | |
4096 | | - | |
4097 | | - | |
| 4096 | + | |
4098 | 4097 | | |
4099 | | - | |
| 4098 | + | |
| 4099 | + | |
| 4100 | + | |
| 4101 | + | |
| 4102 | + | |
| 4103 | + | |
| 4104 | + | |
4100 | 4105 | | |
4101 | 4106 | | |
4102 | 4107 | | |
| |||
4120 | 4125 | | |
4121 | 4126 | | |
4122 | 4127 | | |
4123 | | - | |
| 4128 | + | |
| 4129 | + | |
4124 | 4130 | | |
4125 | 4131 | | |
4126 | 4132 | | |
| |||
4132 | 4138 | | |
4133 | 4139 | | |
4134 | 4140 | | |
4135 | | - | |
| 4141 | + | |
| 4142 | + | |
4136 | 4143 | | |
4137 | 4144 | | |
4138 | 4145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| |||
0 commit comments