Skip to content

Commit 63bb437

Browse files
committed
fix: update deadlock tests
1 parent 4c4089a commit 63bb437

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/test/java/io/supertokens/storage/postgresql/test/DeadlockTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ public void testCodeCreationRapidlyWithDifferentEmails() throws Exception {
265265
assertNull(process
266266
.checkOrWaitForEventInPlugin(
267267
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_NOT_RESOLVED));
268-
assertNotNull(process
268+
269+
// Deadlock doesn't occur with READ_COMMITTED
270+
assertNull(process
269271
.checkOrWaitForEventInPlugin(
270272
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND));
271273

@@ -430,7 +432,9 @@ public void testConcurrentDeleteAndUpdate() throws Exception {
430432
// but t2 (update) should fail because of "could not serialize access"
431433
assertTrue(!t1Failed.get() && !t2Failed.get());
432434
assert (t1State.get().equals("commit") && t2State.get().equals("commit"));
433-
assertNotNull(process.checkOrWaitForEventInPlugin(
435+
436+
// Deadlock doesn't occur with READ_COMMITTED
437+
assertNull(process.checkOrWaitForEventInPlugin(
434438
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND));
435439

436440
process.kill();
@@ -597,7 +601,9 @@ public void testConcurrentDeleteAndInsert() throws Exception {
597601
// but t2 (insert) should fail because of "could not serialize access"
598602
assertTrue(!t1Failed.get() && t2Failed.get());
599603
assert (t1State.get().equals("commit") && t2State.get().equals("query"));
600-
assertNotNull(process
604+
605+
// Deadlock doesn't occur anymore with READ_COMMITTED
606+
assertNull(process
601607
.checkOrWaitForEventInPlugin(
602608
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND,
603609
1000));
@@ -647,7 +653,9 @@ public void testLinkAccountsInParallel() throws Exception {
647653
assertNull(process
648654
.checkOrWaitForEventInPlugin(
649655
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_NOT_RESOLVED));
650-
assertNotNull(process
656+
657+
// Deadlock doesn't occur with READ_COMMITTED
658+
assertNull(process
651659
.checkOrWaitForEventInPlugin(
652660
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND));
653661

@@ -692,7 +700,8 @@ public void testCreatePrimaryInParallel() throws Exception {
692700
assertNull(process
693701
.checkOrWaitForEventInPlugin(
694702
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_NOT_RESOLVED));
695-
assertNotNull(process
703+
// No deadlock happens now with READ_COMMITTED
704+
assertNull(process
696705
.checkOrWaitForEventInPlugin(
697706
io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND));
698707

0 commit comments

Comments
 (0)