Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21a1036

Browse files
committed
Add some isolation tests for CLUSTER
This commit adds two isolation tests for CLUSTER, using:- A normal table, making sure that CLUSTER blocks and completes if thetable is locked by a concurrent session.- A partitioned table with a partition owned by a different user. Ifthe partitioned table is locked by a concurrent session, CLUSTER on thepartitioned table should block. If the partition owned by a differentuser is locked, CLUSTER on its partitioned table should complete andskip the partition.3f19e17 has added an early check to ignore such apartition with a SQL regression test, but this was not checking thatCLUSTER should not block.Discussion:https://postgr.es/m/YlqveniXn9AI6RFZ@paquier.xyz
1 parentb787c55 commit21a1036

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: s1_begin s1_lock_parent s2_auth s2_cluster s1_commit s2_reset
4+
step s1_begin: BEGIN;
5+
step s1_lock_parent: LOCK cluster_part_tab IN SHARE UPDATE EXCLUSIVE MODE;
6+
step s2_auth: SET ROLE regress_cluster_part;
7+
step s2_cluster: CLUSTER cluster_part_tab USING cluster_part_ind; <waiting ...>
8+
step s1_commit: COMMIT;
9+
step s2_cluster: <... completed>
10+
step s2_reset: RESET ROLE;
11+
12+
starting permutation: s1_begin s2_auth s1_lock_parent s2_cluster s1_commit s2_reset
13+
step s1_begin: BEGIN;
14+
step s2_auth: SET ROLE regress_cluster_part;
15+
step s1_lock_parent: LOCK cluster_part_tab IN SHARE UPDATE EXCLUSIVE MODE;
16+
step s2_cluster: CLUSTER cluster_part_tab USING cluster_part_ind; <waiting ...>
17+
step s1_commit: COMMIT;
18+
step s2_cluster: <... completed>
19+
step s2_reset: RESET ROLE;
20+
21+
starting permutation: s1_begin s1_lock_child s2_auth s2_cluster s1_commit s2_reset
22+
step s1_begin: BEGIN;
23+
step s1_lock_child: LOCK cluster_part_tab1 IN SHARE UPDATE EXCLUSIVE MODE;
24+
step s2_auth: SET ROLE regress_cluster_part;
25+
step s2_cluster: CLUSTER cluster_part_tab USING cluster_part_ind;
26+
step s1_commit: COMMIT;
27+
step s2_reset: RESET ROLE;
28+
29+
starting permutation: s1_begin s2_auth s1_lock_child s2_cluster s1_commit s2_reset
30+
step s1_begin: BEGIN;
31+
step s2_auth: SET ROLE regress_cluster_part;
32+
step s1_lock_child: LOCK cluster_part_tab1 IN SHARE UPDATE EXCLUSIVE MODE;
33+
step s2_cluster: CLUSTER cluster_part_tab USING cluster_part_ind;
34+
step s1_commit: COMMIT;
35+
step s2_reset: RESET ROLE;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Parsed test spec with 2 sessions
2+
3+
starting permutation: s1_begin s1_lock s2_auth s2_cluster s1_commit s2_reset
4+
step s1_begin: BEGIN;
5+
step s1_lock: LOCK cluster_tab IN SHARE UPDATE EXCLUSIVE MODE;
6+
step s2_auth: SET ROLE regress_cluster_conflict;
7+
step s2_cluster: CLUSTER cluster_tab USING cluster_ind; <waiting ...>
8+
step s1_commit: COMMIT;
9+
step s2_cluster: <... completed>
10+
step s2_reset: RESET ROLE;
11+
12+
starting permutation: s1_begin s2_auth s1_lock s2_cluster s1_commit s2_reset
13+
step s1_begin: BEGIN;
14+
step s2_auth: SET ROLE regress_cluster_conflict;
15+
step s1_lock: LOCK cluster_tab IN SHARE UPDATE EXCLUSIVE MODE;
16+
step s2_cluster: CLUSTER cluster_tab USING cluster_ind; <waiting ...>
17+
step s1_commit: COMMIT;
18+
step s2_cluster: <... completed>
19+
step s2_reset: RESET ROLE;

‎src/test/isolation/isolation_schedule

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ test: partition-key-update-2
102102
test: partition-key-update-3
103103
test: partition-key-update-4
104104
test: plpgsql-toast
105+
test: cluster-conflict
106+
test: cluster-conflict-partition
105107
test: truncate-conflict
106108
test: serializable-parallel
107109
test: serializable-parallel-2
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Tests for locking conflicts with CLUSTER command and partitions.
2+
3+
setup
4+
{
5+
CREATEROLEregress_cluster_part;
6+
CREATETABLEcluster_part_tab(aint)PARTITIONBYLIST(a);
7+
CREATETABLEcluster_part_tab1PARTITIONOFcluster_part_tabFORVALUESIN(1);
8+
CREATETABLEcluster_part_tab2PARTITIONOFcluster_part_tabFORVALUESIN(2);
9+
CREATEINDEXcluster_part_indONcluster_part_tab(a);
10+
ALTERTABLEcluster_part_tabOWNERTOregress_cluster_part;
11+
}
12+
13+
teardown
14+
{
15+
DROPTABLEcluster_part_tab;
16+
DROPROLEregress_cluster_part;
17+
}
18+
19+
sessions1
20+
steps1_begin{ BEGIN;}
21+
steps1_lock_parent{LOCKcluster_part_tabINSHAREUPDATEEXCLUSIVEMODE;}
22+
steps1_lock_child{LOCKcluster_part_tab1INSHAREUPDATEEXCLUSIVEMODE;}
23+
steps1_commit{COMMIT;}
24+
25+
sessions2
26+
steps2_auth{SETROLEregress_cluster_part;}
27+
steps2_cluster{CLUSTERcluster_part_tabUSINGcluster_part_ind;}
28+
steps2_reset{RESETROLE;}
29+
30+
# CLUSTER on the parent waits if locked, passes for all cases.
31+
permutations1_begins1_lock_parents2_auths2_clusters1_commits2_reset
32+
permutations1_begins2_auths1_lock_parents2_clusters1_commits2_reset
33+
34+
# When taking a lock on a partition leaf, CLUSTER on the parent skips
35+
# the leaf, passes for all cases.
36+
permutations1_begins1_lock_childs2_auths2_clusters1_commits2_reset
37+
permutations1_begins2_auths1_lock_childs2_clusters1_commits2_reset
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Tests for locking conflicts with CLUSTER command.
2+
3+
setup
4+
{
5+
CREATEROLEregress_cluster_conflict;
6+
CREATETABLEcluster_tab(aint);
7+
CREATEINDEXcluster_indONcluster_tab(a);
8+
ALTERTABLEcluster_tabOWNERTOregress_cluster_conflict;
9+
}
10+
11+
teardown
12+
{
13+
DROPTABLEcluster_tab;
14+
DROPROLEregress_cluster_conflict;
15+
}
16+
17+
sessions1
18+
steps1_begin{ BEGIN;}
19+
steps1_lock{LOCKcluster_tabINSHAREUPDATEEXCLUSIVEMODE;}
20+
steps1_commit{COMMIT;}
21+
22+
sessions2
23+
steps2_auth{SETROLEregress_cluster_conflict;}
24+
steps2_cluster{CLUSTERcluster_tabUSINGcluster_ind;}
25+
steps2_reset{RESETROLE;}
26+
27+
# The role has privileges to cluster the table, CLUSTER will block if
28+
# another session holds a lock on the table and succeed in all cases.
29+
permutations1_begins1_locks2_auths2_clusters1_commits2_reset
30+
permutations1_begins2_auths1_locks2_clusters1_commits2_reset

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp