Skip to content

Commit 6698a7d

Browse files
authored
Postgres sixteen version (#1013)
* Add PGDLLEXPORT markings in exported bgworker functions From postgres version 16 onward it is necessary for exported background worker functions to be marked PGDLLEXPORT. Otherwise they are not findable by LookupBackgroundWorkerFunction(). Failing to mark healthcheck entry point functions as such leads to a miss functioning monitor as the child processes will fail to launch yet the monitor will be running. Adding the markings to previous postgres versions does not have any adverse symptoms. Hence this commit adds them unconditionally. * Define bgworker type where missing in healthcheck. The structure member 'bgw_type' is used in various log messages within a postgres process. When undeclared the log messages are filled with random chars resulting to unparseable or broken messages. Additionally by setting 'bgw_type' it is possible to group all healthckeck workers in a process listing.
1 parent f9f4bc5 commit 6698a7d

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/monitor/health_check.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ extern int HealthCheckRetryDelay;
5555
extern size_t HealthCheckWorkerShmemSize(void);
5656

5757
extern void InitializeHealthCheckWorker(void);
58-
extern void HealthCheckWorkerMain(Datum arg);
59-
extern void HealthCheckWorkerLauncherMain(Datum arg);
58+
extern PGDLLEXPORT void HealthCheckWorkerMain(Datum arg);
59+
extern PGDLLEXPORT void HealthCheckWorkerLauncherMain(Datum arg);
6060
extern List * LoadNodeHealthList(void);
6161
extern NodeHealth * TupleToNodeHealth(HeapTuple heapTuple,
6262
TupleDesc tupleDescriptor);

src/monitor/health_check_worker.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ RegisterHealthCheckWorker(DatabaseListEntry *db)
414414
sizeof(worker.bgw_library_name));
415415
strlcpy(worker.bgw_function_name, "HealthCheckWorkerMain",
416416
sizeof(worker.bgw_function_name));
417+
strlcpy(worker.bgw_type, "pgautofailover",
418+
sizeof(worker.bgw_type));
417419
appendStringInfo(&buf, "pg_auto_failover monitor healthcheck worker %s",
418420
db->dbname);
419421
strlcpy(worker.bgw_name, buf.data,

src/monitor/pg_auto_failover.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ StartMonitorNode(void)
195195
strlcpy(worker.bgw_name, "pg_auto_failover monitor", sizeof(worker.bgw_name));
196196
strlcpy(worker.bgw_function_name, "HealthCheckWorkerLauncherMain",
197197
sizeof(worker.bgw_function_name));
198+
strlcpy(worker.bgw_type, "pgautofailover", sizeof(worker.bgw_type));
198199

199200
RegisterBackgroundWorker(&worker);
200201
}

0 commit comments

Comments
 (0)