mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Introduce Streaming Replication.
This includes two new kinds of postmaster processes, walsenders and walreceiver. Walreceiver is responsible for connecting to the primary server and streaming WAL to disk, while walsender runs in the primary server and streams WAL from disk to the client. Documentation still needs work, but the basics are there. We will probably pull the replication section to a new chapter later on, as well as the sections describing file-based replication. But let's do that as a separate patch, so that it's easier to see what has been added/changed. This patch also adds a new section to the chapter about FE/BE protocol, documenting the protocol used by walsender/walreceivxer. Bump catalog version because of two new functions, pg_last_xlog_receive_location() and pg_last_xlog_replay_location(), for monitoring the progress of replication. Fujii Masao, with additional hacking by me
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.255 2010/01/02 16:57:36 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.256 2010/01/15 09:19:00 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -32,6 +32,7 @@
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "postmaster/bgwriter.h"
|
||||
#include "postmaster/walwriter.h"
|
||||
#include "replication/walreceiver.h"
|
||||
#include "storage/bufmgr.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/proc.h"
|
||||
@ -173,7 +174,7 @@ static IndexList *ILHead = NULL;
|
||||
* AuxiliaryProcessMain
|
||||
*
|
||||
* The main entry point for auxiliary processes, such as the bgwriter,
|
||||
* walwriter, bootstrapper and the shared memory checker code.
|
||||
* walwriter, walreceiver, bootstrapper and the shared memory checker code.
|
||||
*
|
||||
* This code is here just because of historical reasons.
|
||||
*/
|
||||
@ -314,6 +315,9 @@ AuxiliaryProcessMain(int argc, char *argv[])
|
||||
case WalWriterProcess:
|
||||
statmsg = "wal writer process";
|
||||
break;
|
||||
case WalReceiverProcess:
|
||||
statmsg = "wal receiver process";
|
||||
break;
|
||||
default:
|
||||
statmsg = "??? process";
|
||||
break;
|
||||
@ -419,6 +423,24 @@ AuxiliaryProcessMain(int argc, char *argv[])
|
||||
WalWriterMain();
|
||||
proc_exit(1); /* should never return */
|
||||
|
||||
case WalReceiverProcess:
|
||||
/* don't set signals, walreceiver has its own agenda */
|
||||
{
|
||||
PGFunction WalReceiverMain;
|
||||
|
||||
/*
|
||||
* Walreceiver is not linked directly into the server
|
||||
* binary because we would then need to link the server
|
||||
* with libpq. It's compiled as a dynamically loaded module
|
||||
* to avoid that.
|
||||
*/
|
||||
WalReceiverMain = load_external_function("walreceiver",
|
||||
"WalReceiverMain",
|
||||
true, NULL);
|
||||
WalReceiverMain(NULL);
|
||||
}
|
||||
proc_exit(1); /* should never return */
|
||||
|
||||
default:
|
||||
elog(PANIC, "unrecognized process type: %d", auxType);
|
||||
proc_exit(1);
|
||||
|
Reference in New Issue
Block a user