aboutsummaryrefslogtreecommitdiff
path: root/src/test/modules/worker_spi/worker_spi.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-08-31 12:24:47 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-09-29 11:08:24 -0400
commit5373bc2a0867048bb78f93aede54ac1309b5e227 (patch)
treea330b6841f88d58831746b8d82e206174234a509 /src/test/modules/worker_spi/worker_spi.c
parent8b304b8b72b0a60f1968d39f01cf817c8df863ec (diff)
downloadpostgresql-5373bc2a0867048bb78f93aede54ac1309b5e227.tar.gz
postgresql-5373bc2a0867048bb78f93aede54ac1309b5e227.zip
Add background worker type
Add bgw_type field to background worker structure. It is intended to be set to the same value for all workers of the same type, so they can be grouped in pg_stat_activity, for example. The backend_type column in pg_stat_activity now shows bgw_type for a background worker. The ps listing also no longer calls out that a process is a background worker but just show the bgw_type. That way, being a background worker is more of an implementation detail now that is not shown to the user. However, most log messages still refer to 'background worker "%s"'; otherwise constructing sensible and translatable log messages would become tricky. Reviewed-by: Michael Paquier <michael.paquier@gmail.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Diffstat (limited to 'src/test/modules/worker_spi/worker_spi.c')
-rw-r--r--src/test/modules/worker_spi/worker_spi.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c
index 12c8cd5774c..4c6ab6d575d 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -111,7 +111,7 @@ initialize_worker_spi(worktable *table)
StartTransactionCommand();
SPI_connect();
PushActiveSnapshot(GetTransactionSnapshot());
- pgstat_report_activity(STATE_RUNNING, "initializing spi_worker schema");
+ pgstat_report_activity(STATE_RUNNING, "initializing worker_spi schema");
/* XXX could we use CREATE SCHEMA IF NOT EXISTS? */
initStringInfo(&buf);
@@ -359,7 +359,8 @@ _PG_init(void)
*/
for (i = 1; i <= worker_spi_total_workers; i++)
{
- snprintf(worker.bgw_name, BGW_MAXLEN, "worker %d", i);
+ snprintf(worker.bgw_name, BGW_MAXLEN, "worker_spi worker %d", i);
+ snprintf(worker.bgw_type, BGW_MAXLEN, "worker_spi");
worker.bgw_main_arg = Int32GetDatum(i);
RegisterBackgroundWorker(&worker);
@@ -385,7 +386,8 @@ worker_spi_launch(PG_FUNCTION_ARGS)
worker.bgw_restart_time = BGW_NEVER_RESTART;
sprintf(worker.bgw_library_name, "worker_spi");
sprintf(worker.bgw_function_name, "worker_spi_main");
- snprintf(worker.bgw_name, BGW_MAXLEN, "worker %d", i);
+ snprintf(worker.bgw_name, BGW_MAXLEN, "worker_spi worker %d", i);
+ snprintf(worker.bgw_type, BGW_MAXLEN, "worker_spi");
worker.bgw_main_arg = Int32GetDatum(i);
/* set bgw_notify_pid so that we can use WaitForBackgroundWorkerStartup */
worker.bgw_notify_pid = MyProcPid;