summaryrefslogtreecommitdiff
path: root/src/backend/postmaster
diff options
context:
space:
mode:
authorPeter Eisentraut2017-01-19 17:00:00 +0000
committerPeter Eisentraut2017-01-20 14:04:49 +0000
commit665d1fad99e7b11678b0d5fa24d2898424243cd6 (patch)
treeeefe3eb528f840780aef6c09939a1844dbabb30a /src/backend/postmaster
parentba61a04bc7fefeee03416d9911eb825c4897c223 (diff)
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>
Diffstat (limited to 'src/backend/postmaster')
-rw-r--r--src/backend/postmaster/bgworker.c23
-rw-r--r--src/backend/postmaster/pgstat.c6
-rw-r--r--src/backend/postmaster/postmaster.c9
3 files changed, 37 insertions, 1 deletions
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 61d3170b839..cd99b0b3927 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -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"
@@ -108,6 +109,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.
*/
Size
@@ -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,
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index f37a0bfaafd..7176cf1bbeb 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -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 */
}
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 5be30b0ee15..8d99c7a0d4e 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -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"
@@ -942,6 +943,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
*/
process_shared_preload_libraries();