mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Logical replication
- Add PUBLICATION catalogs and DDL - Add SUBSCRIPTION catalog and DDL - Define logical replication protocol and output plugin - Add logical replication workers From: Petr Jelinek <petr@2ndquadrant.com> Reviewed-by: Steve Singer <steve@ssinger.info> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Erik Rijkers <er@xs4all.nl> Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "port/atomics.h"
|
||||
#include "postmaster/bgworker_internals.h"
|
||||
#include "postmaster/postmaster.h"
|
||||
#include "replication/logicallauncher.h"
|
||||
#include "storage/dsm.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/latch.h"
|
||||
@@ -107,6 +108,15 @@ struct BackgroundWorkerHandle
|
||||
|
||||
static BackgroundWorkerArray *BackgroundWorkerData;
|
||||
|
||||
/*
|
||||
* List of workers that are allowed to be started outside of
|
||||
* shared_preload_libraries.
|
||||
*/
|
||||
static const bgworker_main_type InternalBGWorkers[] = {
|
||||
ApplyLauncherMain,
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Calculate shared memory needed.
|
||||
*/
|
||||
@@ -761,12 +771,23 @@ RegisterBackgroundWorker(BackgroundWorker *worker)
|
||||
{
|
||||
RegisteredBgWorker *rw;
|
||||
static int numworkers = 0;
|
||||
bool internal = false;
|
||||
int i;
|
||||
|
||||
if (!IsUnderPostmaster)
|
||||
ereport(DEBUG1,
|
||||
(errmsg("registering background worker \"%s\"", worker->bgw_name)));
|
||||
|
||||
if (!process_shared_preload_libraries_in_progress)
|
||||
for (i = 0; InternalBGWorkers[i]; i++)
|
||||
{
|
||||
if (worker->bgw_main == InternalBGWorkers[i])
|
||||
{
|
||||
internal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!process_shared_preload_libraries_in_progress && !internal)
|
||||
{
|
||||
if (!IsUnderPostmaster)
|
||||
ereport(LOG,
|
||||
|
@@ -3303,6 +3303,12 @@ pgstat_get_wait_activity(WaitEventActivity w)
|
||||
case WAIT_EVENT_WAL_WRITER_MAIN:
|
||||
event_name = "WalWriterMain";
|
||||
break;
|
||||
case WAIT_EVENT_LOGICAL_LAUNCHER_MAIN:
|
||||
event_name = "LogicalLauncherMain";
|
||||
break;
|
||||
case WAIT_EVENT_LOGICAL_APPLY_MAIN:
|
||||
event_name = "LogicalApplyMain";
|
||||
break;
|
||||
/* no default case, so that compiler will warn */
|
||||
}
|
||||
|
||||
|
@@ -113,6 +113,7 @@
|
||||
#include "postmaster/pgarch.h"
|
||||
#include "postmaster/postmaster.h"
|
||||
#include "postmaster/syslogger.h"
|
||||
#include "replication/logicallauncher.h"
|
||||
#include "replication/walsender.h"
|
||||
#include "storage/fd.h"
|
||||
#include "storage/ipc.h"
|
||||
@@ -941,6 +942,14 @@ PostmasterMain(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Register the apply launcher. Since it registers a background worker,
|
||||
* it needs to be called before InitializeMaxBackends(), and it's probably
|
||||
* a good idea to call it before any modules had chance to take the
|
||||
* background worker slots.
|
||||
*/
|
||||
ApplyLauncherRegister();
|
||||
|
||||
/*
|
||||
* process any libraries that should be preloaded at postmaster start
|
||||
*/
|
||||
|
Reference in New Issue
Block a user