-
Notifications
You must be signed in to change notification settings - Fork 794
Support concurrent partition detach #8802
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
Open
Andrey Borodin (x4m)
wants to merge
6
commits into
citusdata:main
Choose a base branch
from
x4m:detach-partition-concurrently
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b8f347
Support concurrent partition detach
x4m 71e4944
Apply citus_indent
x4m ca38c8d
Fix style and test isolation
x4m 94ccc43
Merge branch 'main' into detach-partition-concurrently
x4m 7674652
Make concurrent partition detach retryable
x4m 5c69a92
Merge branch 'main' into detach-partition-concurrently
x4m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
src/test/regress/expected/detach_partition_concurrently.out
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| CREATE SCHEMA detach_partition_concurrently; | ||
| SET search_path TO detach_partition_concurrently; | ||
| SET citus.shard_count TO 2; | ||
| SET citus.shard_replication_factor TO 1; | ||
| CREATE TABLE parent (a int) PARTITION BY RANGE (a); | ||
| CREATE TABLE child PARTITION OF parent FOR VALUES FROM (0) TO (10); | ||
| SELECT create_distributed_table('parent', 'a'); | ||
| create_distributed_table | ||
| --------------------------------------------------------------------- | ||
|
|
||
| (1 row) | ||
|
|
||
| ALTER TABLE parent DETACH PARTITION child CONCURRENTLY; | ||
| SELECT relispartition | ||
| FROM pg_class | ||
| WHERE oid = 'child'::regclass; | ||
| relispartition | ||
| --------------------------------------------------------------------- | ||
| f | ||
| (1 row) | ||
|
|
||
| SELECT result | ||
| FROM run_command_on_workers($$ | ||
| SELECT count(*) | ||
| FROM pg_inherits i | ||
| JOIN pg_class p ON p.oid = i.inhparent | ||
| WHERE p.relname LIKE 'parent\_%' | ||
| $$) | ||
| ORDER BY result; | ||
| result | ||
| --------------------------------------------------------------------- | ||
| 0 | ||
| 0 | ||
| (2 rows) | ||
|
|
||
| INSERT INTO child VALUES (1); | ||
| SELECT * FROM child; | ||
| a | ||
| --------------------------------------------------------------------- | ||
| 1 | ||
| (1 row) | ||
|
|
||
| DROP TABLE child; | ||
| DROP TABLE parent; | ||
| DROP SCHEMA detach_partition_concurrently; |
87 changes: 87 additions & 0 deletions
87
src/test/regress/expected/isolation_detach_partition_concurrently.out
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| Parsed test spec with 3 sessions | ||
|
|
||
| starting permutation: s1_begin s1_read s2_detach s3_cancel s3_pending s3_workers_attached s1_commit s3_finalize s3_done s3_workers_done | ||
| create_distributed_table | ||
| --------------------------------------------------------------------- | ||
|
|
||
| (1 row) | ||
|
|
||
| step s1_begin: BEGIN; | ||
| step s1_read: SELECT * FROM detach_parent; | ||
| a | ||
| - | ||
| (0 rows) | ||
|
|
||
| step s2_detach: | ||
| ALTER TABLE detach_parent DETACH PARTITION detach_child CONCURRENTLY; | ||
| <waiting ...> | ||
| step s3_cancel: | ||
| SELECT pg_cancel_backend(pid) | ||
| FROM pg_stat_activity | ||
| WHERE pid <> pg_backend_pid() | ||
| AND query LIKE | ||
| '%ALTER TABLE detach_parent DETACH PARTITION detach_child CONCURRENTLY%'; | ||
|
|
||
| pg_cancel_backend | ||
| --------------------------------------------------------------------- | ||
| t | ||
| (1 row) | ||
|
|
||
| step s2_detach: <... completed> | ||
| ERROR: canceling statement due to user request | ||
| step s3_pending: | ||
| SELECT inhdetachpending | ||
| FROM pg_inherits | ||
| WHERE inhparent = 'detach_parent'::regclass; | ||
|
|
||
| inhdetachpending | ||
| --------------------------------------------------------------------- | ||
| t | ||
| (1 row) | ||
|
|
||
| step s3_workers_attached: | ||
| SELECT result | ||
| FROM run_command_on_workers($$ | ||
| SELECT count(*) | ||
| FROM pg_inherits i | ||
| JOIN pg_class p ON p.oid = i.inhparent | ||
| WHERE p.relname LIKE 'detach_parent\_%' | ||
| $$) | ||
| ORDER BY result; | ||
|
|
||
| result | ||
| --------------------------------------------------------------------- | ||
| 1 | ||
| 1 | ||
| (2 rows) | ||
|
|
||
| step s1_commit: COMMIT; | ||
| step s3_finalize: | ||
| ALTER TABLE detach_parent DETACH PARTITION detach_child FINALIZE; | ||
|
|
||
| step s3_done: | ||
| SELECT relispartition | ||
| FROM pg_class | ||
| WHERE oid = 'detach_child'::regclass; | ||
|
|
||
| relispartition | ||
| --------------------------------------------------------------------- | ||
| f | ||
| (1 row) | ||
|
|
||
| step s3_workers_done: | ||
| SELECT result | ||
| FROM run_command_on_workers($$ | ||
| SELECT count(*) | ||
| FROM pg_inherits i | ||
| JOIN pg_class p ON p.oid = i.inhparent | ||
| WHERE p.relname LIKE 'detach_parent\_%' | ||
| $$) | ||
| ORDER BY result; | ||
|
|
||
| result | ||
| --------------------------------------------------------------------- | ||
| 0 | ||
| 0 | ||
| (2 rows) | ||
|
|
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.