- Notifications
You must be signed in to change notification settings - Fork5.3k
Commita1b8b3b
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 parentfaba259 commita1b8b3b
File tree
2 files changed
+31
-6
lines changed- src
- backend/access/transam
- test/recovery/t
2 files changed
+31
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
| 949 | + | |
949 | 950 | | |
950 | 951 | | |
951 | 952 | | |
| |||
12837 | 12838 | | |
12838 | 12839 | | |
12839 | 12840 | | |
| 12841 | + | |
| 12842 | + | |
| 12843 | + | |
| 12844 | + | |
| 12845 | + | |
12840 | 12846 | | |
12841 | | - | |
| 12847 | + | |
| 12848 | + | |
| 12849 | + | |
| 12850 | + | |
| 12851 | + | |
| 12852 | + | |
12842 | 12853 | | |
12843 | 12854 | | |
12844 | 12855 | | |
| |||
13191 | 13202 | | |
13192 | 13203 | | |
13193 | 13204 | | |
13194 | | - | |
| 13205 | + | |
13195 | 13206 | | |
13196 | | - | |
| 13207 | + | |
13197 | 13208 | | |
13198 | | - | |
13199 | | - | |
13200 | 13209 | | |
13201 | 13210 | | |
13202 | 13211 | | |
13203 | 13212 | | |
13204 | 13213 | | |
| 13214 | + | |
| 13215 | + | |
| 13216 | + | |
| 13217 | + | |
| 13218 | + | |
| 13219 | + | |
| 13220 | + | |
| 13221 | + | |
13205 | 13222 | | |
13206 | 13223 | | |
13207 | 13224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
| |||
0 commit comments
Comments
(0)