summaryrefslogtreecommitdiffstats
path: root/src/test/isolation/specs/deadlock-soft.spec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:15:05 +0000
commit46651ce6fe013220ed397add242004d764fc0153 (patch)
tree6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/test/isolation/specs/deadlock-soft.spec
parentInitial commit. (diff)
downloadpostgresql-14-46651ce6fe013220ed397add242004d764fc0153.tar.xz
postgresql-14-46651ce6fe013220ed397add242004d764fc0153.zip
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/isolation/specs/deadlock-soft.spec')
-rw-r--r--src/test/isolation/specs/deadlock-soft.spec40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/isolation/specs/deadlock-soft.spec b/src/test/isolation/specs/deadlock-soft.spec
new file mode 100644
index 0000000..bc9c6a7
--- /dev/null
+++ b/src/test/isolation/specs/deadlock-soft.spec
@@ -0,0 +1,40 @@
+# Four-process deadlock with two hard edges and two soft edges.
+# d2 waits for e1 (soft edge), e1 waits for d1 (hard edge),
+# d1 waits for e2 (soft edge), e2 waits for d2 (hard edge).
+# The deadlock detector resolves the deadlock by reversing the d1-e2 edge,
+# unblocking d1.
+
+setup
+{
+ CREATE TABLE a1 ();
+ CREATE TABLE a2 ();
+}
+
+teardown
+{
+ DROP TABLE a1, a2;
+}
+
+session d1
+setup { BEGIN; SET deadlock_timeout = '10s'; }
+step d1a1 { LOCK TABLE a1 IN ACCESS SHARE MODE; }
+step d1a2 { LOCK TABLE a2 IN ACCESS SHARE MODE; }
+step d1c { COMMIT; }
+
+session d2
+setup { BEGIN; SET deadlock_timeout = '10ms'; }
+step d2a2 { LOCK TABLE a2 IN ACCESS SHARE MODE; }
+step d2a1 { LOCK TABLE a1 IN ACCESS SHARE MODE; }
+step d2c { COMMIT; }
+
+session e1
+setup { BEGIN; SET deadlock_timeout = '10s'; }
+step e1l { LOCK TABLE a1 IN ACCESS EXCLUSIVE MODE; }
+step e1c { COMMIT; }
+
+session e2
+setup { BEGIN; SET deadlock_timeout = '10s'; }
+step e2l { LOCK TABLE a2 IN ACCESS EXCLUSIVE MODE; }
+step e2c { COMMIT; }
+
+permutation d1a1 d2a2 e1l e2l d1a2 d2a1 d1c e1c d2c e2c