Commit 1b0262a
Ibrar Ahmed
Replace wal_sender_timeout-based liveness with TCP keepalive.
The apply worker previously relied on wal_sender_timeout as both a
server-side disconnect trigger and an indirect keepalive pressure on
the subscriber. This caused spurious disconnects in two scenarios:
a flood of 'w' messages keeping the subscriber too busy to send 'r'
feedback in time, and large transactions whose apply time exceeded
wal_sender_timeout.
The workaround was maybe_send_feedback(), which force-sent 'r' after
every 10 'w' messages or wal_sender_timeout/2, whichever came first.
This was a fragile band-aid that coupled subscriber behavior to a
server GUC it cannot control.
Replace the entire mechanism with a clean two-layer model:
- TCP keepalive (keepalives_idle=10, keepalives_interval=5,
keepalives_count=3) is the primary liveness detector on both sides.
A dead network or crashed host is detected in ~25 seconds.
- wal_sender_timeout=0 is set on replication connections so the
walsender never disconnects due to missing 'r' feedback. Liveness
on the server side is now handled entirely by TCP keepalive.
- spock.apply_idle_timeout (default 300s) is a subscriber-side safety
net for a hung-but-connected walsender whose TCP keepalive probes
are answered by the kernel but sends no data. Set to 0 to disable.
Fix a bug in last_receive_timestamp handling: it was updated
unconditionally after every PQgetCopyData call, including when r==0
(no data available). Each 1-second WL_TIMEOUT spin silently reset
the timer, making apply_idle_timeout never fire. Move the update to
after the r==0 guard so it reflects actual data receipt only.
Remove maybe_send_feedback() as it is no longer needed.1 parent 33a21c9 commit 1b0262a
3 files changed
+55
-62
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
307 | | - | |
| 308 | + | |
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
| |||
345 | 346 | | |
346 | 347 | | |
347 | 348 | | |
348 | | - | |
| 349 | + | |
349 | 350 | | |
350 | 351 | | |
351 | | - | |
| 352 | + | |
352 | 353 | | |
353 | 354 | | |
354 | | - | |
| 355 | + | |
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
359 | 375 | | |
360 | 376 | | |
361 | 377 | | |
| |||
1186 | 1202 | | |
1187 | 1203 | | |
1188 | 1204 | | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
1189 | 1221 | | |
1190 | 1222 | | |
1191 | 1223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | | - | |
234 | 232 | | |
235 | 233 | | |
236 | 234 | | |
| |||
2838 | 2836 | | |
2839 | 2837 | | |
2840 | 2838 | | |
2841 | | - | |
2842 | | - | |
2843 | | - | |
2844 | | - | |
2845 | | - | |
2846 | | - | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
2847 | 2844 | | |
2848 | | - | |
| 2845 | + | |
2849 | 2846 | | |
2850 | 2847 | | |
2851 | 2848 | | |
2852 | 2849 | | |
2853 | | - | |
| 2850 | + | |
2854 | 2851 | | |
2855 | 2852 | | |
2856 | 2853 | | |
2857 | | - | |
2858 | | - | |
2859 | | - | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
2860 | 2857 | | |
2861 | 2858 | | |
2862 | 2859 | | |
| |||
2879 | 2876 | | |
2880 | 2877 | | |
2881 | 2878 | | |
2882 | | - | |
2883 | | - | |
2884 | 2879 | | |
2885 | 2880 | | |
2886 | 2881 | | |
| |||
2912 | 2907 | | |
2913 | 2908 | | |
2914 | 2909 | | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
2915 | 2918 | | |
2916 | 2919 | | |
2917 | 2920 | | |
| |||
2947 | 2950 | | |
2948 | 2951 | | |
2949 | 2952 | | |
2950 | | - | |
2951 | | - | |
2952 | | - | |
2953 | | - | |
2954 | | - | |
2955 | | - | |
2956 | | - | |
2957 | | - | |
2958 | | - | |
2959 | | - | |
2960 | 2953 | | |
2961 | 2954 | | |
2962 | 2955 | | |
| |||
3924 | 3917 | | |
3925 | 3918 | | |
3926 | 3919 | | |
3927 | | - | |
3928 | | - | |
3929 | | - | |
3930 | | - | |
3931 | | - | |
3932 | | - | |
3933 | | - | |
3934 | | - | |
3935 | | - | |
3936 | | - | |
3937 | | - | |
3938 | | - | |
3939 | | - | |
3940 | | - | |
3941 | | - | |
3942 | | - | |
3943 | | - | |
3944 | | - | |
3945 | | - | |
3946 | | - | |
3947 | | - | |
3948 | | - | |
3949 | | - | |
3950 | | - | |
3951 | | - | |
3952 | | - | |
3953 | | - | |
3954 | | - | |
3955 | | - | |
3956 | | - | |
3957 | | - | |
3958 | | - | |
3959 | | - | |
3960 | 3920 | | |
3961 | 3921 | | |
3962 | 3922 | | |
| |||
0 commit comments