]> granicus.if.org Git - postgresql/commit
Make standby server continuously retry restoring the next WAL segment with
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 27 Jan 2010 15:27:51 +0000 (15:27 +0000)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 27 Jan 2010 15:27:51 +0000 (15:27 +0000)
commit1bb2558046cc8b8cb0c8f5563e8d32b3b120c9ec
tree61f6838c88e2a60a3f133d10c2e6352129aaf321
parentab13d1e925691c37bb6fa13cb748867c5ae2a91c
Make standby server continuously retry restoring the next WAL segment with
restore_command, if the connection to the primary server is lost. This
ensures that the standby can recover automatically, if the connection is
lost for a long time and standby falls behind so much that the required
WAL segments have been archived and deleted in the master.

This also makes standby_mode useful without streaming replication; the
server will keep retrying restore_command every few seconds until the
trigger file is found. That's the same basic functionality pg_standby
offers, but without the bells and whistles.

To implement that, refactor the ReadRecord/FetchRecord functions. The
FetchRecord() function introduced in the original streaming replication
patch is removed, and all the retry logic is now in a new function called
XLogReadPage(). XLogReadPage() is now responsible for executing
restore_command, launching walreceiver, and waiting for new WAL to arrive
from primary, as required.

This also changes the life cycle of walreceiver. When launched, it now only
tries to connect to the master once, and exits if the connection fails, or
is lost during streaming for any reason. The startup process detects the
death, and re-launches walreceiver if necessary.
src/backend/access/transam/xlog.c
src/backend/postmaster/postmaster.c
src/backend/replication/walreceiver.c
src/backend/replication/walreceiverfuncs.c
src/include/replication/walreceiver.h
src/include/storage/pmsignal.h