From f160d0800b1e93b0d8630165e003f5fbf97c2f9d Mon Sep 17 00:00:00 2001 From: Joel Dudley Date: Tue, 7 Aug 2018 10:14:23 +0100 Subject: [PATCH 1/3] Typo. (#3750) --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 37dc57e9fa..3050296b7c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,4 +5,4 @@ When reporting an issue please make sure it contains; * A clear description of the issue * Any logs or stack traces that you can provide (use a site like https://pastebin.com for larger logs) * Steps to reproduce the issue -* The version/tag/release or commit hash it occured on \ No newline at end of file +* The version/tag/release or commit hash it occurred on From 6255459ce7fb01d33386176e72ec8cfe44c62196 Mon Sep 17 00:00:00 2001 From: Michele Sollecito Date: Tue, 7 Aug 2018 11:31:10 +0100 Subject: [PATCH 2/3] [CORDA-1880]: Exception if timeout during initial registration (fixed). (#3748) --- .../net/corda/node/internal/NodeStartup.kt | 8 ++++---- .../registration/NetworkRegistrationHelper.kt | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt index fddaeb47eb..6a5e27a3d6 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -23,7 +23,7 @@ import net.corda.node.services.transactions.bftSMaRtSerialFilter import net.corda.node.utilities.createKeyPairAndSelfSignedTLSCertificate import net.corda.node.utilities.registration.HTTPNetworkRegistrationService import net.corda.node.utilities.registration.NodeRegistrationHelper -import net.corda.node.utilities.registration.UnableToRegisterNodeWithDoormanException +import net.corda.node.utilities.registration.NodeRegistrationException import net.corda.node.utilities.saveToKeyStore import net.corda.node.utilities.saveToTrustStore import net.corda.nodeapi.internal.addShutdownHook @@ -140,13 +140,13 @@ open class NodeStartup(val args: Array) { if (cmdlineOptions.nodeRegistrationOption != null) { // Null checks for [compatibilityZoneURL], [rootTruststorePath] and [rootTruststorePassword] has been done in [CmdLineOptions.loadConfig] registerWithNetwork(conf, versionInfo, cmdlineOptions.nodeRegistrationOption) - // At this point the node registration was succesfull. We can delete the marker file. + // At this point the node registration was successful. We can delete the marker file. deleteNodeRegistrationMarker(cmdlineOptions.baseDirectory) return true } logStartupInfo(versionInfo, cmdlineOptions, conf) - } catch (e: UnableToRegisterNodeWithDoormanException) { - logger.warn("Node registration service is unavailable. Perhaps try to perform the initial registration again after a while.") + } catch (e: NodeRegistrationException) { + logger.warn("Node registration service is unavailable. Perhaps try to perform the initial registration again after a while.", e) return false } catch (e: Exception) { logger.error("Exception during node registration", e) diff --git a/node/src/main/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelper.kt b/node/src/main/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelper.kt index b8637baace..4ec5319c28 100644 --- a/node/src/main/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelper.kt +++ b/node/src/main/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelper.kt @@ -18,6 +18,7 @@ import org.bouncycastle.openssl.jcajce.JcaPEMWriter import org.bouncycastle.util.io.pem.PemObject import java.io.IOException import java.io.StringWriter +import java.net.ConnectException import java.nio.file.Path import java.security.KeyPair import java.security.KeyStore @@ -90,7 +91,14 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration, val keyPair = nodeKeyStore.loadOrCreateKeyPair(SELF_SIGNED_PRIVATE_KEY) - val requestId = submitOrResumeCertificateSigningRequest(keyPair) + val requestId = try { + submitOrResumeCertificateSigningRequest(keyPair) + } catch (e: Exception) { + if (e is ConnectException || e is ServiceUnavailableException || e is IOException) { + throw NodeRegistrationException(e) + } + throw e + } val certificates = try { pollServerForCertificates(requestId) @@ -103,7 +111,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration, } validateCertificates(keyPair.public, certificates) storePrivateKeyWithCertificates(nodeKeyStore, keyPair, certificates, keyAlias) - onSuccess(keyPair, certificates, tlsCrlIssuerCert?.let { it.subjectX500Principal.toX500Name() }) + onSuccess(keyPair, certificates, tlsCrlIssuerCert?.subjectX500Principal?.toX500Name()) // All done, clean up temp files. requestIdStore.deleteIfExists() } @@ -183,7 +191,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration, if (idlePeriodDuration != null) { Thread.sleep(idlePeriodDuration.toMillis()) } else { - throw UnableToRegisterNodeWithDoormanException() + throw NodeRegistrationException(e) } } } @@ -232,7 +240,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration, protected open fun isTlsCrlIssuerCertRequired(): Boolean = false } -class UnableToRegisterNodeWithDoormanException : IOException() +class NodeRegistrationException(cause: Throwable?) : IOException("Unable to contact node registration service", cause) class NodeRegistrationHelper(private val config: NodeConfiguration, certService: NetworkRegistrationService, regConfig: NodeRegistrationOption, computeNextIdleDoormanConnectionPollInterval: (Duration?) -> Duration? = FixedPeriodLimitedRetrialStrategy(10, Duration.ofMinutes(1))) : NetworkRegistrationHelper(config, From dd4923e80e69a302d11bd466fb2ef5ccf6892056 Mon Sep 17 00:00:00 2001 From: Thomas Schroeter Date: Tue, 7 Aug 2018 13:24:22 +0100 Subject: [PATCH 3/3] Add jitter to retries (#3749) * Add jitter to retries * Address comments --- .../services/statemachine/SingleThreadedStateMachineManager.kt | 3 ++- node/src/main/resources/reference.conf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt index 40d1c92b99..50252c38be 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt @@ -590,10 +590,11 @@ class SingleThreadedStateMachineManager( private fun scheduleTimeoutException(flow: Flow, retryCount: Int): ScheduledFuture<*> { return with(serviceHub.configuration.flowTimeout) { val timeoutDelaySeconds = timeout.seconds * Math.pow(backoffBase, retryCount.toDouble()).toLong() + val jitteredDelaySeconds = maxOf(1L, timeoutDelaySeconds/2 + (Math.random() * timeoutDelaySeconds/2).toLong()) timeoutScheduler.schedule({ val event = Event.Error(FlowTimeoutException(maxRestartCount)) flow.fiber.scheduleEvent(event) - }, timeoutDelaySeconds, TimeUnit.SECONDS) + }, jitteredDelaySeconds, TimeUnit.SECONDS) } } diff --git a/node/src/main/resources/reference.conf b/node/src/main/resources/reference.conf index 11d4414886..1fdff37987 100644 --- a/node/src/main/resources/reference.conf +++ b/node/src/main/resources/reference.conf @@ -22,6 +22,6 @@ rpcSettings = { } flowTimeout { timeout = 30 seconds - maxRestartCount = 5 + maxRestartCount = 6 backoffBase = 1.8 }