Parallel worker terminated by its leader while RestoreGUCState() is resetting GUCs logs its FATAL with boot-default settings, e.g. timestamps in GMT instead of log_timezone; after f836f25b6f095f3b23762026831d2fab6117087c this hits about a quarter of the workers stopped during startup ============================================================================================================================================================================================================================================================================================ AI-generated bug report from the AI Annex Report ID: 01a23008-13aa-78e5-aef7-c917cd5cf874 Filed: 2026-12-01 05:16:05 UTC Severity: 15/100 Blamed commit: f5d9698a8400972bd604069a3f15ca33e535ea6e ## Summary When a parallel query is cancelled while its workers are starting, the leader terminates them. A worker that is inside RestoreGUCState() when it is told to terminate processes the die interrupt at a CHECK_FOR_INTERRUPTS() reached from a GUC check hook, while RestoreGUCState() has already reset some of the shippable GUCs to their compiled-in defaults and not yet restored the leader's values. Its "terminating background worker "parallel worker" due to administrator command" FATAL (and DETAIL) is therefore emitted with boot-default logging settings. The visible effect is that these log entries carry a GMT timestamp even though log_timezone is set to another zone, so they sort out of place and do not match the server's other entries. The same applies to the timestamp field in jsonlog and csvlog. Since f836f25b6f095f3b23762026831d2fab6117087c ("Detach parallel DSM segment after workers have exited"), a worker that had not started yet when the leader aborted attaches to the segment and runs its normal startup instead of failing to map the segment, so this now happens routinely whenever a parallel query is cancelled early. ## Reproduction postgresql.conf: `log_timezone = 'America/Los_Angeles'` (any zone other than GMT), `max_worker_processes = 16`, `max_parallel_workers = 16`; restart. ``` CREATE TABLE t AS SELECT g FROM generate_series(1, 300000) g; ANALYZE t; ``` File q.sql: ``` SET max_parallel_workers_per_gather = 8; SET parallel_setup_cost = 0; SET parallel_tuple_cost = 0; SET min_parallel_table_scan_size = 0; SET statement_timeout = '3ms'; SELECT count(*) FROM t WHERE g % 7 = 3; ``` ``` for i in $(seq 1 300); do psql -X -q -f q.sql >/dev/null 2>&1; done grep 'parallel worker' | grep -c ' GMT ' ``` Expected: every log entry uses log_timezone. Actual: many parallel-worker entries are stamped GMT, for example ``` ... 21:09:52.800 PST [1049902] parallel worker DETAIL: Signal sent by PID ... ... 05:09:52.800 GMT [1049901] parallel worker FATAL: terminating background worker "parallel worker" due to administrator command ... 21:09:52.800 PST [1049904] parallel worker FATAL: terminating background worker "parallel worker" due to administrator command ``` In one run, 1080 worker log lines were stamped GMT. With `log_destination = 'jsonlog'` and the logging collector, 342 of 1393 worker termination FATALs had a GMT timestamp. ## Analysis src/backend/utils/misc/guc.c, RestoreGUCState(), called from ParallelWorkerMain() inside a transaction, first loops over guc_nondef_list and calls InitializeOneGUCOption() on each shippable variable, which sets it to its boot value (log_timezone boots as GMT), and only then applies the values serialized by the leader. InitializeOneGUCOption() runs check hooks; for example check_default_text_search_config() calls get_ts_config_oid(), whose catalog cache initialization performs heap scans that call CHECK_FOR_INTERRUPTS(). A pending die (SIGTERM from TerminateBackgroundWorker() in the leader's DestroyParallelContext()) is serviced there, and the FATAL is logged while log_timezone and other already-reset variables hold boot defaults. Interrupts are not held across the reset/restore sequence. Observed stack: ProcessInterrupts <- heap_fetch_next_buffer <- ... <- ScanPgRelation <- ... <- CatalogCacheInitializeCache <- ... <- get_ts_config_oid <- check_default_text_search_config <- InitializeOneGUCOption <- RestoreGUCState <- ParallelWorkerMain. In the debugger, log_timezone was "GMT" at that point. The reset-then-restore design dates from the commit that added RestoreGUCState (blame). f836f25b6f0 made it frequent: previously a worker started after the leader had begun aborting failed early in dsm_attach, before RestoreGUCState, and logged in the configured zone. ## Notes Tested on master b7822f9992216f9aa85422337c15f1e7a8d6db72 (cassert build). Only log output of the terminating worker is affected; the query results and the leader are unaffected. Other logging settings that are shippable and reset in the same loop could likewise be at their boot values in that window. ## Branches Reproduced on master. The reset-then-restore window exists in every supported branch (the blamed commit is in REL_14_STABLE and later), but it is frequent only on master, after f836f25b6f095f3b23762026831d2fab6117087c; the release branches were not tested.