|
17 | 17 |
|
18 | 18 | package io.supertokens.storage.postgresql.test; |
19 | 19 |
|
| 20 | +import java.sql.Connection; |
| 21 | +import java.sql.SQLException; |
| 22 | +import java.util.concurrent.ExecutorService; |
| 23 | +import java.util.concurrent.Executors; |
| 24 | +import java.util.concurrent.TimeUnit; |
| 25 | +import java.util.concurrent.atomic.AtomicBoolean; |
| 26 | +import java.util.concurrent.atomic.AtomicLong; |
| 27 | +import java.util.concurrent.atomic.AtomicLongArray; |
| 28 | +import java.util.concurrent.atomic.AtomicReference; |
| 29 | + |
| 30 | +import org.junit.AfterClass; |
| 31 | +import static org.junit.Assert.assertNotNull; |
| 32 | +import static org.junit.Assert.assertNull; |
| 33 | +import static org.junit.Assert.assertTrue; |
| 34 | +import org.junit.Before; |
| 35 | +import org.junit.Rule; |
| 36 | +import org.junit.Test; |
| 37 | +import org.junit.rules.TestRule; |
| 38 | + |
20 | 39 | import io.supertokens.ProcessState; |
21 | 40 | import io.supertokens.authRecipe.AuthRecipe; |
22 | 41 | import io.supertokens.emailpassword.EmailPassword; |
|
32 | 51 | import io.supertokens.pluginInterface.multitenancy.TenantIdentifier; |
33 | 52 | import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException; |
34 | 53 | import io.supertokens.pluginInterface.sqlStorage.SQLStorage; |
35 | | -import io.supertokens.pluginInterface.sqlStorage.SQLStorage.TransactionIsolationLevel; |
36 | 54 | import io.supertokens.pluginInterface.totp.TOTPDevice; |
37 | 55 | import io.supertokens.pluginInterface.totp.TOTPUsedCode; |
38 | 56 | import io.supertokens.pluginInterface.totp.exception.UnknownTotpUserIdException; |
39 | 57 | import io.supertokens.pluginInterface.totp.exception.UsedCodeAlreadyExistsException; |
40 | 58 | import io.supertokens.pluginInterface.totp.sqlStorage.TOTPSQLStorage; |
41 | | -import io.supertokens.storageLayer.StorageLayer; |
42 | | -import org.junit.AfterClass; |
43 | | -import org.junit.Before; |
44 | | -import org.junit.Rule; |
45 | | -import org.junit.Test; |
46 | | -import org.junit.rules.TestRule; |
47 | | - |
48 | | -import java.sql.Connection; |
49 | | -import java.sql.SQLException; |
50 | | -import java.util.concurrent.ExecutorService; |
51 | | -import java.util.concurrent.Executors; |
52 | | -import java.util.concurrent.TimeUnit; |
53 | | -import java.util.concurrent.atomic.AtomicBoolean; |
54 | | -import java.util.concurrent.atomic.AtomicLong; |
55 | | -import java.util.concurrent.atomic.AtomicLongArray; |
56 | | -import java.util.concurrent.atomic.AtomicReference; |
57 | | - |
58 | 59 | import static io.supertokens.storage.postgresql.QueryExecutorTemplate.update; |
59 | | -import static org.junit.Assert.*; |
| 60 | +import io.supertokens.storageLayer.StorageLayer; |
60 | 61 |
|
61 | 62 | public class DeadlockTest { |
62 | 63 | @Rule |
@@ -266,8 +267,7 @@ public void testCodeCreationRapidlyWithDifferentEmails() throws Exception { |
266 | 267 | .checkOrWaitForEventInPlugin( |
267 | 268 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_NOT_RESOLVED)); |
268 | 269 |
|
269 | | - // Deadlock doesn't occur with READ_COMMITTED |
270 | | - assertNull(process |
| 270 | + assertNotNull(process |
271 | 271 | .checkOrWaitForEventInPlugin( |
272 | 272 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND)); |
273 | 273 |
|
@@ -433,8 +433,7 @@ public void testConcurrentDeleteAndUpdate() throws Exception { |
433 | 433 | assertTrue(!t1Failed.get() && !t2Failed.get()); |
434 | 434 | assert (t1State.get().equals("commit") && t2State.get().equals("commit")); |
435 | 435 |
|
436 | | - // Deadlock doesn't occur with READ_COMMITTED |
437 | | - assertNull(process.checkOrWaitForEventInPlugin( |
| 436 | + assertNotNull(process.checkOrWaitForEventInPlugin( |
438 | 437 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND)); |
439 | 438 |
|
440 | 439 | process.kill(); |
@@ -520,7 +519,7 @@ public void testConcurrentDeleteAndInsert() throws Exception { |
520 | 519 | t1Failed.set(false); |
521 | 520 |
|
522 | 521 | return null; |
523 | | - }, TransactionIsolationLevel.READ_COMMITTED); |
| 522 | + }/*, TransactionIsolationLevel.READ_COMMITTED */); |
524 | 523 | } catch (StorageQueryException | StorageTransactionLogicException e) { |
525 | 524 | // This is expected because of "could not serialize access" |
526 | 525 | t1Failed.set(true); |
@@ -602,8 +601,7 @@ public void testConcurrentDeleteAndInsert() throws Exception { |
602 | 601 | assertTrue(!t1Failed.get() && t2Failed.get()); |
603 | 602 | assert (t1State.get().equals("commit") && t2State.get().equals("query")); |
604 | 603 |
|
605 | | - // Deadlock doesn't occur anymore with READ_COMMITTED |
606 | | - assertNull(process |
| 604 | + assertNotNull(process |
607 | 605 | .checkOrWaitForEventInPlugin( |
608 | 606 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND, |
609 | 607 | 1000)); |
@@ -654,7 +652,6 @@ public void testLinkAccountsInParallel() throws Exception { |
654 | 652 | .checkOrWaitForEventInPlugin( |
655 | 653 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_NOT_RESOLVED)); |
656 | 654 |
|
657 | | - // Deadlock doesn't occur with READ_COMMITTED |
658 | 655 | assertNull(process |
659 | 656 | .checkOrWaitForEventInPlugin( |
660 | 657 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND)); |
@@ -700,8 +697,7 @@ public void testCreatePrimaryInParallel() throws Exception { |
700 | 697 | assertNull(process |
701 | 698 | .checkOrWaitForEventInPlugin( |
702 | 699 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_NOT_RESOLVED)); |
703 | | - // No deadlock happens now with READ_COMMITTED |
704 | | - assertNull(process |
| 700 | + assertNotNull(process |
705 | 701 | .checkOrWaitForEventInPlugin( |
706 | 702 | io.supertokens.storage.postgresql.ProcessState.PROCESS_STATE.DEADLOCK_FOUND)); |
707 | 703 |
|
|
0 commit comments