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

PG17 - Add Regression Test for Access Method Behavior on Partitioned Tables #7818

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

m3hm3t
Copy link
Contributor

@m3hm3t m3hm3t commented Dec 27, 2024

This PR adds a regression test to verify the behavior of access methods for partitioned and distributed tables, including:

  • Creating partitioned tables with heap.
  • Distributing tables using create_distributed_table.
  • Switching access methods to columnar with ALTER TABLE.
  • Validating access method inheritance for new partitions.

@m3hm3t m3hm3t self-assigned this Dec 27, 2024
Copy link

codecov bot commented Dec 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-13.0@103125f). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff               @@
##             release-13.0    #7818   +/-   ##
===============================================
  Coverage                ?   89.63%           
===============================================
  Files                   ?      274           
  Lines                   ?    59748           
  Branches                ?     7452           
===============================================
  Hits                    ?    53556           
  Misses                  ?     4058           
  Partials                ?     2134           

@m3hm3t m3hm3t requested a review from naisila December 30, 2024 07:39
@m3hm3t m3hm3t marked this pull request as ready for review December 30, 2024 07:39

(1 row)

-- Step 4: Verify that the table and partitions are created and distributed correctly
Copy link
Member

Choose a reason for hiding this comment

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

We have to verify step 4 in one of the worker nodes as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added


-- Step 5: Test ALTER TABLE ... SET ACCESS METHOD to a different method
ALTER TABLE test_partitioned_alter SET ACCESS METHOD columnar;
-- Step 6: Verify the change is applied to future partitions
Copy link
Member

@naisila naisila Dec 30, 2024

Choose a reason for hiding this comment

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

similarly we have to verify step 5&6 in one of the worker nodes as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Member

@naisila naisila left a comment

Choose a reason for hiding this comment

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

I was trying to verify -- Step 5: Test ALTER TABLE ... SET ACCESS METHOD to a different method in the worker nodes and I ran into a problem: the access method of the partitions is not updated! So, this PR needs code changes. The following output is from one of the worker nodes:

postgres=# \d+ test_partitioned_alter
                            Partitioned table "public.test_partitioned_alter"
...
Partitions: test_partition_1 FOR VALUES FROM (0) TO (100),
            test_partition_2 FOR VALUES FROM (100) TO (200)
Access method: columnar



postgres=# \d+ test_partition_1
                                     Table "public.test_partition_1"
...
Partition of: test_partitioned_alter FOR VALUES FROM (0) TO (100)
...
Access method: heap

@m3hm3t m3hm3t marked this pull request as draft December 30, 2024 08:28
Copy link
Member

@naisila naisila left a comment

Choose a reason for hiding this comment

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

I just checked with the Postgres commit, and actually the existing partitions are not modified.

Specifying an AM for a partitioned table lets the value be used for all future partitions created under it, closely mirroring the behavior of the TABLESPACE option for partitioned
tables. Existing partitions are not modified.

Therefore, Citus is behaving correctly.

We need to modify the tests a little bit, I will leave some comments.

@naisila naisila marked this pull request as ready for review December 30, 2024 18:47
@naisila naisila self-requested a review December 30, 2024 18:47
Comment on lines 795 to 925
-- Step 4: Verify that the table and partitions are created and distributed correctly
SELECT relname, relam
FROM pg_class
WHERE relname = 'test_partitioned_alter';

-- Check the partitions' access methods
SELECT relname, relam
FROM pg_class
WHERE relname IN ('test_partition_1', 'test_partition_2')
ORDER BY relname;
Copy link
Member

Choose a reason for hiding this comment

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

We should repeat these steps in one of the worker nodes as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

-- Step 6: Verify the change is applied to future partitions
CREATE TABLE test_partition_3 PARTITION OF test_partitioned_alter
FOR VALUES FROM (200) TO (300);

Copy link
Member

Choose a reason for hiding this comment

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

Between step 5 and step 6 we should add another step 4 (in the coordinator) to verify that the access method in the distributed parent changed, but it didn't change in the existing partitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@m3hm3t m3hm3t force-pushed the m3hm3t/allow_access_part_table branch 2 times, most recently from 0709c77 to 97e4e1f Compare December 31, 2024 10:47
@m3hm3t m3hm3t requested a review from naisila December 31, 2024 13:25
@m3hm3t m3hm3t force-pushed the m3hm3t/allow_access_part_table branch from aaa940a to 947cd4d Compare December 31, 2024 14:19
@m3hm3t m3hm3t force-pushed the m3hm3t/allow_access_part_table branch from 947cd4d to 7d61038 Compare December 31, 2024 15:09
update

update

fix whitespace

update
@m3hm3t m3hm3t force-pushed the m3hm3t/allow_access_part_table branch from 7d61038 to 280456f Compare December 31, 2024 15:10
@naisila naisila merged commit a5780c5 into release-13.0 Dec 31, 2024
158 of 159 checks passed
@naisila naisila deleted the m3hm3t/allow_access_part_table branch December 31, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants