diff --git a/src/main/java/io/supertokens/storage/postgresql/Start.java b/src/main/java/io/supertokens/storage/postgresql/Start.java index 0798d221..37d03fe0 100644 --- a/src/main/java/io/supertokens/storage/postgresql/Start.java +++ b/src/main/java/io/supertokens/storage/postgresql/Start.java @@ -231,9 +231,9 @@ public T startTransaction(TransactionLogic logic, TransactionIsolationLev // we have deadlock as well due to the DeadlockTest.java exceptionMessage.toLowerCase().contains("deadlock"); - if ((isPSQLRollbackException || isDeadlockException) && tries < 3) { + if ((isPSQLRollbackException || isDeadlockException) && tries < 20) { try { - Thread.sleep((long) (10 + (Math.random() * 20))); + Thread.sleep((long) (10 + Math.min(tries, 10) * (Math.random() * 20))); } catch (InterruptedException ignored) { } ProcessState.getInstance(this).addState(ProcessState.PROCESS_STATE.DEADLOCK_FOUND, e);