summaryrefslogtreecommitdiffstats
path: root/src/test/isolation/specs/nowait-2.spec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
commit311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 (patch)
tree0ec307299b1dada3701e42f4ca6eda57d708261e /src/test/isolation/specs/nowait-2.spec
parentInitial commit. (diff)
downloadpostgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.tar.xz
postgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.zip
Adding upstream version 15.4.upstream/15.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/isolation/specs/nowait-2.spec')
-rw-r--r--src/test/isolation/specs/nowait-2.spec37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/isolation/specs/nowait-2.spec b/src/test/isolation/specs/nowait-2.spec
new file mode 100644
index 0000000..cf892f2
--- /dev/null
+++ b/src/test/isolation/specs/nowait-2.spec
@@ -0,0 +1,37 @@
+# Test NOWAIT with multixact locks.
+
+setup
+{
+ CREATE TABLE foo (
+ id int PRIMARY KEY,
+ data text NOT NULL
+ );
+ INSERT INTO foo VALUES (1, 'x');
+}
+
+teardown
+{
+ DROP TABLE foo;
+}
+
+session s1
+setup { BEGIN; }
+step s1a { SELECT * FROM foo FOR SHARE NOWAIT; }
+step s1b { COMMIT; }
+
+session s2
+setup { BEGIN; }
+step s2a { SELECT * FROM foo FOR SHARE NOWAIT; }
+step s2b { SELECT * FROM foo FOR UPDATE NOWAIT; }
+step s2c { COMMIT; }
+
+# s1 and s2 both get SHARE lock, creating a multixact lock, then s2
+# tries to upgrade to UPDATE but aborts because it cannot acquire a
+# multi-xact lock
+permutation s1a s2a s2b s1b s2c
+# the same but with the SHARE locks acquired in a different order, so
+# s2 again aborts because it can't acquired a multi-xact lock
+permutation s2a s1a s2b s1b s2c
+# s2 acquires SHARE then UPDATE, then s1 tries to acquire SHARE but
+# can't so aborts because it can't acquire a regular lock
+permutation s2a s2b s1a s1b s2c