![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Background worker that launches and supervises the managed KCMCP knowledge-compiler server (the "managed mode" of the KCMCP client). More...
#include "postgres.h"#include "miscadmin.h"#include "pgstat.h"#include "lib/stringinfo.h"#include "postmaster/bgworker.h"#include "postmaster/postmaster.h"#include "storage/latch.h"#include "storage/ipc.h"#include "utils/guc.h"#include <string.h>#include <signal.h>#include <unistd.h>#include <sys/wait.h>#include <errno.h>#include "provsql_utils.h"#include "provsql_shmem.h"#include "provsql_error.h"
Go to the source code of this file.
Macros | |
| #define | WL_EXIT_ON_PM_DEATH WL_POSTMASTER_DEATH |
Functions | |
| static void | kcmcp_sigterm (SIGNAL_ARGS) |
| static void | kcmcp_sighup (SIGNAL_ARGS) |
| const char * | provsql_kcmcp_managed_endpoint (void) |
| Read the live endpoint of the managed KCMCP server from shared memory (e.g. | |
| static void | publish_endpoint (const char *endpoint) |
| static char * | build_server_command (const char *tmpl, const char *endpoint) |
| static pid_t | launch_server (const char *cmd) |
| static void | kill_server (pid_t child) |
| static bool | kcmcp_wait (long timeout_ms) |
| void | provsql_kcmcp_worker (Datum ignored) |
| void | RegisterProvSQLKCMCPWorker (void) |
| Register the supervisor background worker that launches and supervises the managed KCMCP server; called from _PG_init alongside the mmap worker. | |
Variables | |
| static volatile sig_atomic_t | got_sigterm = false |
| static volatile sig_atomic_t | got_sighup = false |
Background worker that launches and supervises the managed KCMCP knowledge-compiler server (the "managed mode" of the KCMCP client).
When the provsql.kcmcp_server GUC is non-empty it is a shell command to start a KCMCP server (see doc/source/dev/kc-server-protocol.rst), with the literal {endpoint} replaced by a Unix-socket path this worker picks. The worker forks/execs that command in its own process group, publishes the endpoint in shared memory (read by the in-extension client, kcmcp_client.cpp, for a registry record whose endpoint is 'managed'), and supervises it: on the server's exit it relaunches, on a config reload it restarts a changed command, and on shutdown it kills the whole group. When the GUC is empty the worker simply idles on its latch.
Modeled on RegisterProvSQLMMapWorker (src/provsql_mmap.c); like it, the worker needs only BGWORKER_SHMEM_ACCESS (no database connection): the GUC is a process-global and the endpoint lives in the shared segment.
Definition in file kcmcp_supervisor.c.
| #define WL_EXIT_ON_PM_DEATH WL_POSTMASTER_DEATH |
Definition at line 44 of file kcmcp_supervisor.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| const char * provsql_kcmcp_managed_endpoint | ( | void | ) |
Read the live endpoint of the managed KCMCP server from shared memory (e.g.
"unix:/tmp/..."), or an empty string when none is running.
Definition at line 66 of file kcmcp_supervisor.c.


| void provsql_kcmcp_worker | ( | Datum | ignored | ) |
|
static |
Definition at line 78 of file kcmcp_supervisor.c.


| void RegisterProvSQLKCMCPWorker | ( | void | ) |
Register the supervisor background worker that launches and supervises the managed KCMCP server; called from _PG_init alongside the mmap worker.
Definition at line 236 of file kcmcp_supervisor.c.

|
static |
Definition at line 48 of file kcmcp_supervisor.c.
|
static |
Definition at line 47 of file kcmcp_supervisor.c.