mirror of
https://github.com/corda/corda.git
synced 2024-12-29 01:08:57 +00:00
* Default autoCommit to false, remove setting of autocommit and only set isolationLevel if it's changed. * Set default transaction isolation from database config
This commit is contained in:
parent
0c646ff662
commit
40edc286f5
@ -35,7 +35,8 @@ enum class TransactionIsolationLevel {
|
|||||||
/**
|
/**
|
||||||
* The JDBC constant value of the same name but prefixed with TRANSACTION_ defined in [java.sql.Connection].
|
* The JDBC constant value of the same name but prefixed with TRANSACTION_ defined in [java.sql.Connection].
|
||||||
*/
|
*/
|
||||||
val jdbcValue: Int = java.sql.Connection::class.java.getField("TRANSACTION_$name").get(null) as Int
|
val jdbcString = "TRANSACTION_$name"
|
||||||
|
val jdbcValue: Int = java.sql.Connection::class.java.getField(jdbcString).get(null) as Int
|
||||||
}
|
}
|
||||||
|
|
||||||
class CordaPersistence(
|
class CordaPersistence(
|
||||||
|
@ -20,8 +20,10 @@ class DatabaseTransaction(
|
|||||||
cordaPersistence.dataSource.connection
|
cordaPersistence.dataSource.connection
|
||||||
.apply {
|
.apply {
|
||||||
_connectionCreated = true
|
_connectionCreated = true
|
||||||
autoCommit = false
|
// only set the transaction isolation level if it's actually changed - setting isn't free.
|
||||||
transactionIsolation = isolation
|
if (transactionIsolation != isolation) {
|
||||||
|
transactionIsolation = isolation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,13 @@ data class NodeConfigurationImpl(
|
|||||||
require(security == null || rpcUsers.isEmpty()) {
|
require(security == null || rpcUsers.isEmpty()) {
|
||||||
"Cannot specify both 'rpcUsers' and 'security' in configuration"
|
"Cannot specify both 'rpcUsers' and 'security' in configuration"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure our datasource configuration is sane
|
||||||
|
require(dataSourceProperties.get("autoCommit") != true) { "Datbase auto commit cannot be enabled, Corda requires transactional behaviour" }
|
||||||
|
dataSourceProperties.set("autoCommit", false)
|
||||||
|
if (dataSourceProperties.get("transactionIsolation") == null) {
|
||||||
|
dataSourceProperties["transactionIsolation"] = database.transactionIsolationLevel.jdbcString
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user