diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt index 0db8ac43b1..51ba4eeb40 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt @@ -227,6 +227,15 @@ class CordaPersistence( } } + /** + * Executes given statement in the scope of transaction with the transaction level specified at the creation time. + * @param statement to be executed in the scope of this transaction. + * @param recoverableFailureTolerance number of transaction commit retries for SQL while SQL exception is encountered. + */ + fun transaction(recoverableFailureTolerance: Int, statement: DatabaseTransaction.() -> T): T { + return transaction(defaultIsolationLevel, recoverableFailureTolerance, false, statement) + } + private fun inTopLevelTransaction(isolationLevel: TransactionIsolationLevel, recoverableFailureTolerance: Int, recoverAnyNestedSQLException: Boolean, statement: DatabaseTransaction.() -> T): T { var recoverableFailureCount = 0 diff --git a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt index f1feeb7f5d..cbda649ab1 100644 --- a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt +++ b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt @@ -368,7 +368,7 @@ abstract class AbstractNode(val configuration: NodeConfiguration, } // Do all of this in a database transaction so anything that might need a connection has one. - return database.transaction { + return database.transaction(recoverableFailureTolerance = 0) { networkParametersStorage.setCurrentParameters(signedNetParams, trustRoot) identityService.loadIdentities(nodeInfo.legalIdentitiesAndCerts) attachments.start()