[COMMITTERS] pgsql: Avoid slow shutdown of pg_basebackup. - Mailing list pgsql-committers

From Tom Lane
Subject [COMMITTERS] pgsql: Avoid slow shutdown of pg_basebackup.
Date
Msg-id E1d3rsS-0000WW-Fc@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Avoid slow shutdown of pg_basebackup.

pg_basebackup's child process did not pay any attention to the pipe
from its parent while waiting for input from the source server.
If no server data was arriving, it would only wake up and check the
pipe every standby_message_timeout or so.  This creates a problem
since the parent process might determine and send the desired stop
position only after the server has reached end-of-WAL and stopped
sending data.  In the src/test/recovery regression tests, the timing
is repeatably such that it takes nearly 10 seconds for the child
process to realize that it should shut down.  It's not clear how
often that would happen in real-world cases, but it sure seems like
a bug --- and if the user turns off standby_message_timeout or sets
it very large, the delay could be a lot worse.

To fix, expand the StreamCtl API to allow the pipe input FD to be
passed down to the low-level wait routine, and watch both sockets
when sleeping.

(Note: AFAICS this issue doesn't affect the Windows port, since
it doesn't rely on a pipe to transfer the stop position to the
child thread.)

Discussion: https://postgr.es/m/6456.1493263884@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7834d20b57a4320308c3f8262fabf898f89e6a71

Modified Files
--------------
src/bin/pg_basebackup/pg_basebackup.c |  5 +++
src/bin/pg_basebackup/pg_receivewal.c |  1 +
src/bin/pg_basebackup/receivelog.c    | 78 ++++++++++++++++++++++-------------
src/bin/pg_basebackup/receivelog.h    |  3 ++
4 files changed, 59 insertions(+), 28 deletions(-)


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: [COMMITTERS] pgsql: Fix bug so logical rep launcher saves correctly time of laststa
Next
From: Andres Freund
Date:
Subject: [COMMITTERS] pgsql: Don't use on-disk snapshots for exported logical decodingsnapsh