summaryrefslogtreecommitdiffstats
path: root/src/test/isolation/specs/vacuum-conflict.spec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:19:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:19:15 +0000
commit6eb9c5a5657d1fe77b55cc261450f3538d35a94d (patch)
tree657d8194422a5daccecfd42d654b8a245ef7b4c8 /src/test/isolation/specs/vacuum-conflict.spec
parentInitial commit. (diff)
downloadpostgresql-13-6eb9c5a5657d1fe77b55cc261450f3538d35a94d.tar.xz
postgresql-13-6eb9c5a5657d1fe77b55cc261450f3538d35a94d.zip
Adding upstream version 13.4.upstream/13.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/isolation/specs/vacuum-conflict.spec')
-rw-r--r--src/test/isolation/specs/vacuum-conflict.spec51
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