Skip to content

Commit 5dbca63

Browse files
committed
Restrict bgw_log_level GUC to PostgreSQL 18 and earlier
PostgreSQL 19 allows log_min_messages to be set per process type, for example "warning, bgworker:debug1", which supersedes our timescaledb.bgw_log_level GUC. Only define the GUC and set the background worker log level from it on earlier versions; on PostgreSQL 19 the native per-process-type setting is used instead. Upstream changes: Allow log_min_messages to be set per process type. postgres/postgres@38e0190ced
1 parent fac2e5c commit 5dbca63

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/bgw/job.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,9 @@ ts_bgw_job_entrypoint(PG_FUNCTION_ARGS)
11341134

11351135
BackgroundWorkerInitializeConnectionByOid(db_oid, params.user_oid, 0);
11361136

1137+
#if PG19_LT
11371138
log_min_messages = ts_guc_bgw_log_level;
1139+
#endif
11381140

11391141
elog(DEBUG2, "job %d started execution", params.job_id);
11401142

src/bgw/scheduler.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,9 @@ ts_bgw_scheduler_process(int32 run_for_interval_ms,
855855
TimestampTz start = ts_timer_get_current_timestamp();
856856
TimestampTz quit_time = DT_NOEND;
857857

858+
#if PG19_LT
858859
log_min_messages = ts_guc_bgw_log_level;
860+
#endif
859861

860862
pgstat_report_activity(STATE_RUNNING, NULL);
861863

@@ -916,7 +918,9 @@ ts_bgw_scheduler_process(int32 run_for_interval_ms,
916918
{
917919
got_SIGHUP = false;
918920
ProcessConfigFile(PGC_SIGHUP);
921+
#if PG19_LT
919922
log_min_messages = ts_guc_bgw_log_level;
923+
#endif
920924
}
921925

922926
/*
@@ -1015,7 +1019,9 @@ ts_bgw_scheduler_register_signal_handlers(void)
10151019
/* Some SIGHUPS may already have been dropped, so we must load the file here */
10161020
got_SIGHUP = false;
10171021
ProcessConfigFile(PGC_SIGHUP);
1022+
#if PG19_LT
10181023
log_min_messages = ts_guc_bgw_log_level;
1024+
#endif
10191025
}
10201026

10211027
Datum

src/guc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ static const struct config_enum_entry telemetry_level_options[] = {
5050
#endif
5151

5252
/* Copied from contrib/auto_explain/auto_explain.c */
53+
#if PG19_LT
54+
/*
55+
* PG19 lets log_min_messages be set per process type (e.g. "warning,
56+
* bgworker:debug1"), which supersedes our timescaledb.bgw_log_level GUC, so we
57+
* only define it on earlier versions.
58+
* https://github.com/postgres/postgres/commit/38e0190ced
59+
*/
5360
static const struct config_enum_entry loglevel_options[] = {
5461
{ "debug5", DEBUG5, false }, { "debug4", DEBUG4, false }, { "debug3", DEBUG3, false },
5562
{ "debug2", DEBUG2, false }, { "debug1", DEBUG1, false }, { "debug", DEBUG2, true },
5663
{ "info", INFO, false }, { "notice", NOTICE, false }, { "warning", WARNING, false },
5764
{ "log", LOG, false }, { "error", ERROR, false }, { "fatal", FATAL, false },
5865
{ NULL, 0, false }
5966
};
67+
#endif
6068

6169
static const struct config_enum_entry compress_truncate_behaviour_options[] = {
6270
{ "truncate_only", COMPRESS_TRUNCATE_ONLY, false },
@@ -136,7 +144,9 @@ TSDLLEXPORT bool ts_guc_enable_compression_ratio_warnings = true;
136144
* disabled, regular sequence scans will be used instead. */
137145
TSDLLEXPORT bool ts_guc_enable_columnarscan = true;
138146
TSDLLEXPORT bool ts_guc_enable_columnarindexscan = true;
147+
#if PG19_LT
139148
TSDLLEXPORT int ts_guc_bgw_log_level = WARNING;
149+
#endif
140150
TSDLLEXPORT bool ts_guc_enable_skip_scan = true;
141151
TSDLLEXPORT bool ts_guc_enable_skip_scan_for_distinct_aggregates = true;
142152
TSDLLEXPORT bool ts_guc_enable_compressed_skip_scan = true;
@@ -1510,6 +1520,7 @@ _guc_init(void)
15101520
/* assign_hook= */ ts_license_guc_assign_hook,
15111521
/* show_hook= */ NULL);
15121522

1523+
#if PG19_LT
15131524
DefineCustomEnumVariable(MAKE_EXTOPTION("bgw_log_level"),
15141525
"Log level for the background worker subsystem",
15151526
"Log level for the scheduler and workers of the background worker "
@@ -1522,6 +1533,7 @@ _guc_init(void)
15221533
NULL,
15231534
NULL,
15241535
NULL);
1536+
#endif
15251537

15261538
/* this information is useful in general on customer deployments */
15271539
DefineCustomBoolVariable(/* name= */ MAKE_EXTOPTION("debug_compression_path_info"),

src/guc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ extern TSDLLEXPORT bool ts_guc_enable_composite_bloom_indexes;
117117
extern TSDLLEXPORT bool ts_guc_read_legacy_bloom1_v1;
118118
extern TSDLLEXPORT bool ts_guc_enable_columnarscan;
119119
extern TSDLLEXPORT bool ts_guc_enable_columnarindexscan;
120+
#if PG19_LT
120121
extern TSDLLEXPORT int ts_guc_bgw_log_level;
122+
#endif
121123

122124
/*
123125
* Exit code to use when scheduler exits.

0 commit comments

Comments
 (0)