-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PG17 compatibility: fix multi-1 diffs caused by PG17 optimizer enhancements #7769
PG17 compatibility: fix multi-1 diffs caused by PG17 optimizer enhancements #7769
Conversation
2d0e9ae
to
41b873f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release-13.0 #7769 +/- ##
===============================================
Coverage ? 89.64%
===============================================
Files ? 274
Lines ? 59591
Branches ? 7436
===============================================
Hits ? 53421
Misses ? 4038
Partials ? 2132 |
41b873f
to
0ec4a68
Compare
a12026b
to
6be0649
Compare
6be0649
to
a8139f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good analysis in the PR description, thanks!
SELECT * FROM articles_hash WHERE author_id = 1; | ||
DEBUG: Distributed planning for a fast-path router query | ||
DEBUG: Creating router plan | ||
DEBUG: query has a single distribution column value: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This debug is actually useful to see.
Also, we see the extra pg_temp debugs in 3 tests:
multi_router_planner
, multi_mx_router_planner
, multi_router_planner_fast_path
I think we qualify for a normalize rule here :) Something like:
/DEBUG: drop auto-cascades to type(.*)pg_temp_(.*)/d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.. this would delete lines matching the PG17 DEBUG message from all .out files, right?
Thanks for the suggestion! Agreed that its good to preserve the existing DEBUG messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would delete lines matching the PG17 DEBUG message from all .out files
Hopefully yes
c815325
to
0c54b22
Compare
0ec4a68
to
f4e9d99
Compare
3d03727
to
f051940
Compare
multi_router_planner_fast_path and query_single_shard_table Restore the expected DEBUG error messages from the router planner. In the case of query_single_shard_table the diffs are because of PG17's ability to pull up correlated ANY subqueries (*). The fix is to inhibit pull up with a volatile function. In the case of multi_router_planner and multi_router_planner_fast_path the diffs are because of PG17's ability to remove redundant IS (NOT) NULL expressions (**). The fix is to adjust the table definition so the column used for distribution is not marked NOT NULL. Finally, add a rule to normalize.sed to ignore additional DEBUG logging by CREATE MATERIALIZED VIEW (postgres commit b4da732fd64). This was also impacting regress test multi_mx_router_planner. (*) https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=9f1337639 (**) https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=b262ad440
f051940
to
007dab8
Compare
This is the final commit that adds PG17 compatibility with Citus's current capabilities. You can use Citus community, release-13.0 branch, with PG17.1. --------- Specifically, this commit: - Enables PG17 in the configure script. - Adds PG17 tests to CI using test images that have 17.1 - Fixes an upgrade test: see below for details In `citus_prepare_upgrade()`, don't drop any_value when upgrading from PG16+, because PG16+ has its own any_value function. Attempting to do so results in the error seen in [pg16-pg17 upgrade](https://github.com/citusdata/citus/actions/runs/11768444117/job/32778340003?pr=7661): ``` ERROR: cannot drop function any_value(anyelement) because it is required by the database system CONTEXT: SQL statement "DROP AGGREGATE IF EXISTS pg_catalog.any_value(anyelement)" ``` When 16 becomes the minimum supported Postgres version, the drop statements can be removed. --------- Several PG17 Compatibility commits have been merged before this final one. All these subtasks are done #7653 See the list below: Compilation PR: #7699 Ruleutils PR: #7725 Sister PR for tests: citusdata/the-process#159 Helpful smaller PRs: - #7714 - #7726 - #7731 - #7732 - #7733 - #7738 - #7745 - #7747 - #7748 - #7749 - #7752 - #7755 - #7757 - #7759 - #7760 - #7761 - #7762 - #7765 - #7766 - #7768 - #7769 - #7771 - #7774 - #7776 - #7780 - #7781 - #7785 - #7788 - #7793 - #7796 --------- Co-authored-by: Colm <[email protected]>
This fix ensures that the expected DEBUG error messages from the router planner in
multi_router_planner
,multi_router_planner_fast_path
andquery_single_shard_table
are present with PG17.In
query_single_shard_table
the diff:occurred because of this PG17 commit which enables the optimizer to pull up a correlated ANY subquery to a join. The fix inhibits subquery pull up by including a volatile function in the predicate involving the ANY subquery, preserving the pre-PG17 optimizer treatment of the query.
In the case of
multi_router_planner
andmulti_router_planner_fast_path
the diffs:are because of this PG17 commit, which enables the optimizer to detect and remove redundant IS (NOT) NULL expressions. The fix is to adjust the table definition so the column used for distribution is not marked NOT NULL, thus preserving the pre-PG17 query planning behavior.
Finallly, the DEBUG logging level is lowered for CREATE MATERIALIZED VIEW AS statements in
multi_router_planner
andmulti_router_planner_fast_path
because of this PG17 commit; when creating materialized views, use REFRESH logic to load data, a consequence of which is that withclient_min_messages
atDEBUG2
Postgres emits extra detail for CREATE MATERIALIZED VIEW AS statements.Note: the number part can vary. This is because of the REFRESH logic added by the aforementioned commit. Also relevant is this PG17 commit which sets the search_path to 'pg_catalog, pg_temp' during maintenance operations (including REFRESH MATERIALIZED VIEW)