[CORDA-2807] Don't retry db transaction in AbstactNode start (#4942)

Retries can lead to confusing error messages in case the CFT notary is
misconfigured and throws a SQLException causing a retry.
This commit is contained in:
Thomas Schroeter 2019-03-29 09:41:39 +00:00 committed by josecoll
parent d9e11b21ae
commit dc46446432
2 changed files with 10 additions and 1 deletions

View File

@ -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 <T> transaction(recoverableFailureTolerance: Int, statement: DatabaseTransaction.() -> T): T {
return transaction(defaultIsolationLevel, recoverableFailureTolerance, false, statement)
}
private fun <T> inTopLevelTransaction(isolationLevel: TransactionIsolationLevel, recoverableFailureTolerance: Int, private fun <T> inTopLevelTransaction(isolationLevel: TransactionIsolationLevel, recoverableFailureTolerance: Int,
recoverAnyNestedSQLException: Boolean, statement: DatabaseTransaction.() -> T): T { recoverAnyNestedSQLException: Boolean, statement: DatabaseTransaction.() -> T): T {
var recoverableFailureCount = 0 var recoverableFailureCount = 0

View File

@ -368,7 +368,7 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
} }
// Do all of this in a database transaction so anything that might need a connection has one. // 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) networkParametersStorage.setCurrentParameters(signedNetParams, trustRoot)
identityService.loadIdentities(nodeInfo.legalIdentitiesAndCerts) identityService.loadIdentities(nodeInfo.legalIdentitiesAndCerts)
attachments.start() attachments.start()