Skip to content

Commit 0af2eb1

Browse files
committed
fix(connector-corda): contract deployment SSH reconnect race condition
When deploying multiple contracts on multiple nodes, there are multiple SSH connections being established. When this all happens on the same host (because you are running the all-in-one image for example) then the closing and opening of the same SSH port is not instant between disconnect and connect operations of the SSH client and connectivity problems come up. Due to lack of time I quickly fixed this by adding a 5 second wait between the disconnect and connect operations. Retries would be a much better solution long term especially since race conditions can never truly be fixed with hardcoded wait times that will sooner or later become too short or too long depending on the exact nature of the problem. [skip ci] Signed-off-by: Peter Somogyvari <[email protected]>
1 parent 0085f34 commit 0af2eb1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/cactus-plugin-ledger-connector-corda/src/main-server/kotlin/gen/kotlin-spring/src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/impl/ApiPluginLedgerConnectorCordaServiceImpl.kt

+5
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ class ApiPluginLedgerConnectorCordaServiceImpl(
292292
try {
293293
ssh.disconnect()
294294
logger.debug("Disconnected OK from SSH host ${cred.hostname}:${cred.port}")
295+
// This is a hack to force the code to wait for the OS to close down the port. Without it, deployments
296+
// can fail intermittently because it'll try to reconnect too fast. The right way to fix it is
297+
// to make it probe the port openness and have retries with exponential backoff.
298+
// TODO: Implement the proper fix as described above.
299+
Thread.sleep(5000)
295300
} catch (ex: Exception) {
296301
logger.warn("Disconnect failed from SSH host ${cred.hostname}:${cred.port}. Ignoring since we are done anyway...")
297302
}

0 commit comments

Comments
 (0)