If RegisterBackgroundWorker() (the non-dynamic kind that is only loadable from shared_preload_libraries) fails to register the worker, it writes a log message and proceeds, ignoring the registration request. I think that is a mistake, it should be a hard error. The only way in practice to fix the problem is to change shared_preload_libraries or max_worker_processes, both requiring a restart anyway, so proceeding without the worker is not useful.
Perhaps this kind of worker has not been widely used in practice, but we now have the logical replication launcher registering that way, and the auto-prewarm patch also proposes to add one. If you run out of worker slots before the launcher is supposed to start, it just logs a message and doesn't start. That seems prone to confuse. Attached is a proposed patch (0002) to change the log level to ERROR. The other patch (0001) gives some additional error context for the log/error message that you get. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 38c89ce84e5e4eadf88f432ee0c416121a5fc33b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Tue, 14 Feb 2017 10:39:06 -0500 Subject: [PATCH 1/3] Add errcontext to background worker registration --- src/backend/postmaster/bgworker.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index cd99b0b392..db25a7f68b 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -824,7 +824,8 @@ RegisterBackgroundWorker(BackgroundWorker *worker) "Up to %d background workers can be registered with the current settings.", max_worker_processes, max_worker_processes), - errhint("Consider increasing the configuration parameter \"max_worker_processes\"."))); + errhint("Consider increasing the configuration parameter \"max_worker_processes\"."), + errcontext("registration of background worker \"%s\"", worker->bgw_name))); return; } -- 2.11.1
From 6d2f6ec75f160dce622d77ac55bc50858c337527 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Tue, 14 Feb 2017 10:39:51 -0500 Subject: [PATCH 2/3] Change failures in RegisterBackgroundWorker() to hard errors Previously, just a log message was written and the background worker registration was ignored. --- src/backend/postmaster/bgworker.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index db25a7f68b..a42bd0f758 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -790,19 +790,19 @@ RegisterBackgroundWorker(BackgroundWorker *worker) if (!process_shared_preload_libraries_in_progress && !internal) { if (!IsUnderPostmaster) - ereport(LOG, + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("background worker \"%s\": must be registered in shared_preload_libraries", worker->bgw_name))); return; } - if (!SanityCheckBackgroundWorker(worker, LOG)) + if (!SanityCheckBackgroundWorker(worker, ERROR)) return; if (worker->bgw_notify_pid != 0) { - ereport(LOG, + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("background worker \"%s\": only dynamic background workers can request notification", worker->bgw_name))); @@ -817,7 +817,7 @@ RegisterBackgroundWorker(BackgroundWorker *worker) */ if (++numworkers > max_worker_processes) { - ereport(LOG, + ereport(ERROR, (errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED), errmsg("too many background workers"), errdetail_plural("Up to %d background worker can be registered with the current settings.", @@ -835,7 +835,7 @@ RegisterBackgroundWorker(BackgroundWorker *worker) rw = malloc(sizeof(RegisteredBgWorker)); if (rw == NULL) { - ereport(LOG, + ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); return; -- 2.11.1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers