diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt index 370c686545..ca66a1a2a9 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt @@ -46,13 +46,13 @@ class DatabaseConfig private constructor( */ var defaultRepetitionAttempts: Int = 3, /** - * The minimum time to wait before retrying a transaction if SQLException happens + * The minimum number of milliseconds to wait before retrying a transaction if SQLException happens * Can be overridden on per-transaction level by specifying `minRepetitionDelay` parameter on call * Default minimum delay is 0 */ var defaultMinRepetitionDelay: Long = 0, /** - * The maximum time to wait before retrying a transaction if SQLException happens + * The maximum number of milliseconds to wait before retrying a transaction if SQLException happens * Can be overridden on per-transaction level by specifying `maxRepetitionDelay` parameter on call * Default maximum delay is 0 */ diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt index c2e334ff0c..0807dbb0b7 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt @@ -250,15 +250,15 @@ fun inTopLevelTransaction( } // set delay value val delay = if (minRepetitionDelay < maxRepetitionDelay) { - minRepetitionDelay + Random(System.currentTimeMillis()).nextLong(maxRepetitionDelay - minRepetitionDelay) + Random(System.currentTimeMillis()).nextLong(minRepetitionDelay, maxRepetitionDelay) } else if (minRepetitionDelay == maxRepetitionDelay) { minRepetitionDelay } else { 0 } - exposedLogger.warn("Wait $delay seconds before retrying") + exposedLogger.warn("Wait $delay milliseconds before retrying") try { - Thread.sleep(delay * 1000) + Thread.sleep(delay) } catch (e: InterruptedException) { // Do nothing }