postgresql/src
Peter Eisentraut 086221cf6b Prevent panic during shutdown checkpoint
When the checkpointer writes the shutdown checkpoint, it checks
afterwards whether any WAL has been written since it started and throws
a PANIC if so.  At that point, only walsenders are still active, so one
might think this could not happen, but walsenders can also generate WAL,
for instance in BASE_BACKUP and certain variants of
CREATE_REPLICATION_SLOT.  So they can trigger this panic if such a
command is run while the shutdown checkpoint is being written.

To fix this, divide the walsender shutdown into two phases.  First, the
postmaster sends a SIGUSR2 signal to all walsenders.  The walsenders
then put themselves into the "stopping" state.  In this state, they
reject any new commands.  (For simplicity, we reject all new commands,
so that in the future we do not have to track meticulously which
commands might generate WAL.)  The checkpointer waits for all walsenders
to reach this state before proceeding with the shutdown checkpoint.
After the shutdown checkpoint is done, the postmaster sends
SIGINT (previously unused) to the walsenders.  This triggers the
existing shutdown behavior of sending out the shutdown checkpoint record
and then terminating.

Author: Michael Paquier <michael.paquier@gmail.com>
Reported-by: Fujii Masao <masao.fujii@gmail.com>
2017-05-05 10:31:42 -04:00
..
backend Prevent panic during shutdown checkpoint 2017-05-05 10:31:42 -04:00
bin Fix wording in pg_upgrade docs 2017-05-05 12:42:21 +02:00
common Add PQencryptPasswordConn function to libpq, use it in psql and createuser. 2017-05-03 11:19:07 +03:00
fe_utils Allow psql variable substitution to occur in backtick command strings. 2017-04-01 21:44:54 -04:00
include Prevent panic during shutdown checkpoint 2017-05-05 10:31:42 -04:00
interfaces Misc cleanup of SCRAM code. 2017-05-05 10:01:44 +03:00
makefiles Try to fix non-MSVC Windows builds in the wake of logical replication. 2017-01-20 12:51:31 -05:00
pl Improve castNode notation by introducing list-extraction-specific variants. 2017-04-10 13:51:53 -04:00
port Run the postmaster's signal handlers without SA_RESTART. 2017-04-24 13:00:30 -04:00
template Remove "sco" and "unixware" ports. 2016-10-11 11:26:04 -04:00
test Make SCRAM salts and nonces longer. 2017-05-05 10:02:13 +03:00
timezone Improve performance of timezone loading, especially pg_timezone_names view. 2017-05-02 21:50:35 -04:00
tools Build pgoutput.dll in MSVC build 2017-05-05 12:08:48 +02:00
tutorial Recommend wrappers of PG_DETOAST_DATUM_PACKED(). 2017-03-12 19:35:33 -04:00
.gitignore
DEVELOPERS
Makefile Remove redundant coverage target 2017-02-17 08:56:57 -05:00
Makefile.global.in Remove use of Jade and DSSSL 2017-04-06 22:09:11 -04:00
Makefile.shlib Remove support for bcc and msvc standalone libpq builds 2017-04-11 15:22:21 +02:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00