Hi Kirill, The fix looks right to me. Your test fails 10 of 10 runs on master and passes 10 of 10 with the fix.
A new walsender still fails, because its reader starts with seg.ws_tli = 0, so the first read never uses the buffers. If I terminate the paused walsender in your test, the receiver never catches up, with or without the fix. Passing sendTimeLine fixes it for me when wal_buffers is larger than a segment. Test and change attached. Also, the pg_stat_io check passes without the fix too, so I would drop it. And since 16 never read from the buffers, I would keep this to master. Thanks, Shihao
nocfbot-0001-reconnect-test.patch
Description: Binary data
nocfbot-0002-pass-sendTimeLine.patch
Description: Binary data
