- Notifications
You must be signed in to change notification settings - Fork5.2k
Commit17b2d5e
committed
Fix unconditional WAL receiver shutdown during stream-archive transition
Commitb4f584f (affecting v15~, later backpatched down to 13 as of3635a0a) introduced an unconditional WAL receiver shutdown whenswitching from streaming to archive WAL sources. This causes problemsduring a timeline switch, when a WAL receiver enters WALRCV_WAITINGstate but remains alive, waiting for instructions.The unconditional shutdown can break some monitoring scenarios as theWAL receiver gets repeatedly terminated and re-spawned, causingpg_stat_wal_receiver.status to show a "streaming" instead of "waiting"status, masking the fact that the WAL receiver is waiting for a new TLIand a new LSN to be able to continue streaming.This commit changes the WAL receiver behavior so as the shutdown becomesconditional, with InstallXLogFileSegmentActive being always reset toprevent the regression fixed byb4f584f: only terminate the WALreceiver when it is actively streaming (WALRCV_STREAMING,WALRCV_STARTING, or WALRCV_RESTARTING). When in WALRCV_WAITING state,just reset InstallXLogFileSegmentActive flag to allow archiverestoration without killing the process. WALRCV_STOPPED andWALRCV_STOPPING are not reachable states in this code path. For thelatter, the startup process is the one in charge of settingWALRCV_STOPPING via ShutdownWalRcv(), waiting for the WAL receiver toreach a WALRCV_STOPPED state after switching walRcvState, soWaitForWALToBecomeAvailable() cannot be reached while a WAL receiver isin a WALRCV_STOPPING state.A regression test is added to check that a WAL receiver is not stoppedon timeline jump, that fails when the fix of this commit is reverted.Reported-by: Ryan Bird <ryanzxg@gmail.com>Author: Xuneng Zhou <xunengzhou@gmail.com>Reviewed-by: Noah Misch <noah@leadboat.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/19093-c4fff49a608f82a0@postgresql.orgBackpatch-through: 131 parent8b18ed6 commit17b2d5e
File tree
4 files changed
+31
-5
lines changed- src
- backend/access/transam
- include/access
- test/recovery/t
4 files changed
+31
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9519 | 9519 | | |
9520 | 9520 | | |
9521 | 9521 | | |
9522 | | - | |
9523 | | - | |
9524 | | - | |
9525 | | - | |
| 9522 | + | |
9526 | 9523 | | |
9527 | 9524 | | |
9528 | 9525 | | |
| |||
9534 | 9531 | | |
9535 | 9532 | | |
9536 | 9533 | | |
| 9534 | + | |
| 9535 | + | |
| 9536 | + | |
| 9537 | + | |
| 9538 | + | |
| 9539 | + | |
| 9540 | + | |
| 9541 | + | |
| 9542 | + | |
9537 | 9543 | | |
9538 | 9544 | | |
9539 | 9545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3687 | 3687 | | |
3688 | 3688 | | |
3689 | 3689 | | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
3690 | 3696 | | |
3691 | | - | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
3692 | 3703 | | |
3693 | 3704 | | |
3694 | 3705 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
0 commit comments
Comments
(0)