diff options
Diffstat (limited to 'src/test/isolation/specs/vacuum-conflict.spec')
-rw-r--r-- | src/test/isolation/specs/vacuum-conflict.spec | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/test/isolation/specs/vacuum-conflict.spec b/src/test/isolation/specs/vacuum-conflict.spec new file mode 100644 index 0000000..3cb8926 --- /dev/null +++ b/src/test/isolation/specs/vacuum-conflict.spec @@ -0,0 +1,51 @@ +# Tests for locking conflicts with VACUUM and ANALYZE commands. + +setup +{ + CREATE ROLE regress_vacuum_conflict; + CREATE TABLE vacuum_tab (a int); +} + +teardown +{ + DROP TABLE vacuum_tab; + DROP ROLE regress_vacuum_conflict; +} + +session s1 +step s1_begin { BEGIN; } +step s1_lock { LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; } +step s1_commit { COMMIT; } + +session s2 +step s2_grant { ALTER TABLE vacuum_tab OWNER TO regress_vacuum_conflict; } +step s2_auth { SET ROLE regress_vacuum_conflict; } +step s2_vacuum { VACUUM vacuum_tab; } +step s2_analyze { ANALYZE vacuum_tab; } +step s2_reset { RESET ROLE; } + +# The role doesn't have privileges to vacuum the table, so VACUUM should +# immediately skip the table without waiting for a lock. +permutation s1_begin s1_lock s2_auth s2_vacuum s1_commit s2_reset +permutation s1_begin s2_auth s2_vacuum s1_lock s1_commit s2_reset +permutation s1_begin s2_auth s1_lock s2_vacuum s1_commit s2_reset +permutation s2_auth s2_vacuum s1_begin s1_lock s1_commit s2_reset + +# Same as previously for ANALYZE +permutation s1_begin s1_lock s2_auth s2_analyze s1_commit s2_reset +permutation s1_begin s2_auth s2_analyze s1_lock s1_commit s2_reset +permutation s1_begin s2_auth s1_lock s2_analyze s1_commit s2_reset +permutation s2_auth s2_analyze s1_begin s1_lock s1_commit s2_reset + +# The role has privileges to vacuum the table, VACUUM will block if +# another session holds a lock on the table and succeed in all cases. +permutation s1_begin s2_grant s1_lock s2_auth s2_vacuum s1_commit s2_reset +permutation s1_begin s2_grant s2_auth s2_vacuum s1_lock s1_commit s2_reset +permutation s1_begin s2_grant s2_auth s1_lock s2_vacuum s1_commit s2_reset +permutation s2_grant s2_auth s2_vacuum s1_begin s1_lock s1_commit s2_reset + +# Same as previously for ANALYZE +permutation s1_begin s2_grant s1_lock s2_auth s2_analyze s1_commit s2_reset +permutation s1_begin s2_grant s2_auth s2_analyze s1_lock s1_commit s2_reset +permutation s1_begin s2_grant s2_auth s1_lock s2_analyze s1_commit s2_reset +permutation s2_grant s2_auth s2_analyze s1_begin s1_lock s1_commit s2_reset |