Skip to content
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

Move pg_dist_object to pg_catalog #5765

Merged
merged 17 commits into from
Mar 4, 2022
Merged

Move pg_dist_object to pg_catalog #5765

merged 17 commits into from
Mar 4, 2022

Conversation

thanodnl
Copy link
Member

@thanodnl thanodnl commented Mar 4, 2022

DESCRIPTION: Move pg_dist_object to pg_catalog

Historically pg_dist_object had been created in the citus schema as an experiment to understand if we could move our catalog tables to a branded schema. We quickly realised that this interfered with the UX on our managed services and other environments, where users connected via a user with the name of citus.

By default postgres put the username on the search_path. To be able to read the catalog in the citus schema we would need to grant access permissions to the schema. This caused newly created objects like tables etc, to default to this schema for creation. This failed due to the write permissions to that schema.

With this change we move the pg_dist_object catalog table to the pg_catalog schema, where our other schema's are also located. This makes the catalog table visible and readable by any user, like our other catalog tables, for debugging purposes.

Note: due to the change of schema, we had to disable 1 test that was running into a discrepancy between the schema and binary. Secondly, we needed to make the lookup functions for the pg_dist_object relation and their indexes less strict on the fallback of the naming due to an other test that, due to an unfortunate cache invalidation, needed to lookup the relation again. This makes that we won't default to only resolving from pg_catalog outside of upgrades.

Comment on lines +495 to +505
-- TODO: This test should be moved to a valid downgrade testing suite where the downgrade is done, both on the schema and the binaries. Later changes in Citus made a C vs Schema discrepancy error here
-- BEGIN;
-- SET citus.enable_metadata_sync TO on;
-- SELECT master_add_node('localhost', :master_port, groupId=>0);
-- CREATE TABLE citus_local_table (a int);
-- SELECT create_citus_local_table('citus_local_table');
-- RESET citus.enable_metadata_sync;
--
-- -- downgrade from 9.5-1 to 9.4-1 should fail as we have a citus local table
-- ALTER EXTENSION citus UPDATE TO '9.4-1';
-- ROLLBACK;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test runs into schema vs binary incompatibility.

Have disabled it for now, would be great to have more robust downgrade tests where binary and schema actually do conform.

Copy link
Member

@marcocitus marcocitus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good and straight-forward

-- downgrade from 9.5-1 to 9.4-1 should fail as we have a citus local table
ALTER EXTENSION citus UPDATE TO '9.4-1';
ROLLBACK;
-- TODO: This test should be moved to a valid downgrade testing suite where the downgrade is done, both on the schema and the binaries. Later changes in Citus made a C vs Schema discrepancy error here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably also quite well-covered by the regression tests of previous releases and no longer that relevant.

@thanodnl thanodnl enabled auto-merge (squash) March 4, 2022 17:28
@thanodnl thanodnl merged commit 3801576 into master Mar 4, 2022
@thanodnl thanodnl deleted the move-pg-dist-object branch March 4, 2022 17:40
hanefi added a commit that referenced this pull request Oct 6, 2022
Citus 11 moved `pg_dist_object` to `pg_catalog`. When doing a downgrade,
for a brief period of time, Citus 10.2 expects to have this table in
`citus` schema, but fails. This can potentially cause failures in
downgrade.

We now search for the relation in the `citus` schema and if that fails,
we search in the `pg_catalog` schema.

Related: #5765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants