Skip to content

Commit

Permalink
IsAutoCommit = false & transactionIsolation = "Transaction_Serializab…
Browse files Browse the repository at this point in the history
…le" result in a PSQLException #1575
  • Loading branch information
Tapac committed Nov 14, 2022
1 parent 2bea43b commit dfb63d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class ExposedBlob(val inputStream: InputStream) {
if (this === other) return true
if (other !is ExposedBlob) return false


if (!bytes.contentEquals(other.bytes)) return false

return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ class ThreadLocalTransactionManager(
private val connectionLazy = lazy(LazyThreadSafetyMode.NONE) {
outerTransaction?.connection ?: db.connector().apply {
setupTxConnection?.invoke(this, this@ThreadLocalTransaction) ?: run {
// The order of `setReadOnly` and `setAutoCommit` is important.
// The order of setters here is important.
// Transaction isolation should go first as the readOnly or autoCommit can start transaction with wrong isolation level
// Some drivers start a transaction right after `setAutoCommit(false)`,
// which makes `setReadOnly` throw an exception if it is called after `setAutoCommit`
readOnly = this@ThreadLocalTransaction.readOnly
transactionIsolation = this@ThreadLocalTransaction.transactionIsolation
readOnly = this@ThreadLocalTransaction.readOnly
autoCommit = false
}
}
Expand Down

0 comments on commit dfb63d2

Please sign in to comment.