PG19: fix runtime bugs hit outside the regression suite#8617
Open
ihalatci wants to merge 4 commits into
Open
Conversation
DESCRIPTION: Port upstream PG19 ruleutils.c into Citus deparser tree. Mirrors #8010 (PG18) and #7725 (PG17). Replaces the ruleutils_19.c placeholder from the build-foundation PR with a proper port of upstream PG19's src/backend/utils/adt/ruleutils.c, produced by a 3-way merge (git merge-file: ruleutils_18.c as base, upstream PG18 and upstream PG19 as the two sides). All merge conflicts fell in blocks Citus had already stripped from _18.c or in shard-aware deparse variants, and were resolved by keeping the Citus side. The file keeps Citus' existing curation (deparse hooks, shard-aware UPDATE/DELETE branches) while picking up real upstream PG18->PG19 deparse changes. Without this, Citus on a PG19 backend would deparse worker-bound SQL using PG18 semantics -- silent corruption the moment a PG19-only node, clause, or formatting decision appears in the tree. The trailing #endif guard text is corrected to "(PG_VERSION_NUM >= PG_VERSION_19) && (PG_VERSION_NUM < PG_VERSION_20)" (the _17.c/_18.c snapshots carry stale guard comments; not propagated). The generate_function_name fgc_flags fix is absorbed naturally by the merge -- upstream PG19 already passes &fgc_flags at that call site. Excluded from citus-style via .gitattributes (added in the build-foundation PR): the file exceeds the CI uncrustify 10,000-line limit and is upstream-derived. Refs: #8597
- Replace the blanket `#define totaltime query_instr` with a scoped QueryDescTotalTime() accessor (plus a matching pre-PG19 macro) so the rename no longer risks rewriting unrelated identifiers; convert the multi_executor.c call sites accordingly. - Drop the dead currentProc advance at the end of the dclist_foreach loop in AddEdgesForWaitQueue. - Pass a named Size local to ShmemInitStruct in MaintenanceDaemonShmemInit. - Reserve 1024 * PG_CACHE_LINE_SIZE (instead of a magic 128 * 1024) for the PG19 shmem alignment slack, with an explanatory comment. - Point the columnar get_relation_info_hook TODO and the RepackStmt / LWLock tranche comments at their tracking issues (#8614, #8613, #8609).
Enable PG19beta1 across the downstream test matrices now that the build job proves it compiles: - test-citus, test-citus-failure, test-citus-cdc: add pg19_version - test-arbitrary-configs: add pg19_version to the matrix - test-pg-upgrade: add 18->19 and 16->19 upgrade pairs - params: bump pg19_version/upgrade_pg_versions 19devel -> 19beta1 - params: point image_suffix at the PG19beta1 the-process images (-dev-33b3cf5, built from citusdata/the-process#222) test-citus-upgrade is left at PG16/PG17 (no released Citus supports PG19). Closes #8615
This was referenced Jun 13, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## pg19-ci-test-matrices #8617 +/- ##
=========================================================
+ Coverage 88.77% 88.94% +0.16%
=========================================================
Files 288 288
Lines 64364 64368 +4
Branches 8093 8092 -1
=========================================================
+ Hits 57140 57251 +111
+ Misses 4891 4780 -111
- Partials 2333 2337 +4 🚀 New features to boost your workflow:
|
89495aa to
9d9144a
Compare
Two PG19 runtime crashes that surface in normal Citus operation (not just the regression tests): 1. FuncnameGetCandidates() gained an int *fgc_flags out-parameter that the callee writes to unconditionally; the compat shim passed NULL and crashed on every by-name function lookup (e.g. the maintenance daemon). Pass the address of an int compound literal instead. 2. PG19 added TupleDesc->firstNonCachedOffsetAttr, an offset cache that BlessTupleDesc()/slot_deform_heap_tuple() now assert is populated but no longer populate themselves. Wrap BlessTupleDesc to call TupleDescFinalize() first, add a no-op shim on older majors, and call it explicitly at the three sites that deform hand-built TupleDescs. Also installs ApplicationNameAssignHook via union access on PG19. DESCRIPTION: Fix PG19 runtime crashes in function lookup and TupleDesc handling Closes #8610 Part of #8597
9d9144a to
3a0a90e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR is part of the PG19 support stack and addresses PG19-only runtime crashes by updating Citus compatibility shims and ensuring newly-required tuple descriptor finalization is performed before slot deformation.
Changes:
- Fix PG19
FuncnameGetCandidates()compatibility shim by providing a validfgc_flagsout-parameter. - Ensure PG19 TupleDesc offset-cache initialization via
TupleDescFinalize()(including a PG19BlessTupleDesc()wrapper and explicit finalize calls at key call sites). - Update GUC override logic for PG19’s
config_genericlayout change when installing theapplication_nameassign hook.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/include/pg_version_compat.h | Updates PG19 compatibility macros (fgc_flags shim; TupleDescFinalize + BlessTupleDesc wrapper; no-op TupleDescFinalize on older majors). |
| src/backend/distributed/stats/query_stats.c | Finalizes SRF-provided TupleDesc before using it with slot deformation on PG19. |
| src/backend/distributed/shared_library_init.c | Adjusts PG19 GUC struct access to install ApplicationNameAssignHook safely. |
| src/backend/distributed/planner/multi_explain.c | Finalizes a hand-built TupleDesc used for EXPLAIN ANALYZE result collection on PG19. |
| src/backend/distributed/executor/distributed_intermediate_results.c | Finalizes hand-built TupleDescs used with tuple deformation/processing on PG19. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+200
to
+201
| #define BlessTupleDesc(td) \ | ||
| (TupleDescFinalize(td), (BlessTupleDesc) (td)) |
ad4ccab to
2a197c5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PR (PR2 of the PG19 stack). Base =
pg19-ci-test-matrices(#8616), which is itself stacked onpg19-ruleutils-port(#8602) →pg19-support. Review/merge in stack order.Fixes two PG19 runtime crashes that surface in normal Citus operation (outside the regression suite):
FuncnameGetCandidates()gained anint *fgc_flagsout-parameter that the callee writes to unconditionally. The compat shim passedNULLand crashed on every by-name function lookup (e.g. the maintenance daemon). Now passes the address of an int compound literal.TupleDesc->firstNonCachedOffsetAttr: PG19 added an offset cache thatBlessTupleDesc()/slot_deform_heap_tuple()now assert is populated but no longer populate themselves.BlessTupleDescis wrapped to callTupleDescFinalize()first (no-op shim on older majors), with explicit calls added at the three sites that deform hand-built TupleDescs.Also installs
ApplicationNameAssignHookvia union access on PG19.Closes #8610
Part of #8597