From ad9f7406bc008b53360c571d464750c1792b52ab Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Tue, 13 Oct 2026 10:50:04 +0200 Subject: [PATCH] api: replace the executor client on any transport error The Thrift concurrent client marks itself bad (stop_ set for good) on any receive error, but the node replaced it only on NOT_OPEN, that is when the next call had already failed. One timeout or dropped connection therefore failed the following contract call too, on this node only, and a late reply to a timed-out call could still arrive on the old connection. Replace the client on every TTransportException; the watcher reconnects as before. Co-Authored-By: Claude Opus 5.5 --- api/src/executor.cpp | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/api/src/executor.cpp b/api/src/executor.cpp index 0553c7f9b..54c162764 100644 --- a/api/src/executor.cpp +++ b/api/src/executor.cpp @@ -70,10 +70,9 @@ void cs::Executor::executeByteCodeMultiple(executor::ExecuteByteCodeMultipleResu origExecutor_->executeByteCodeMultiple(_return, static_cast(accessId), initiatorAddress, invokedContract, method, params, executionTime, EXECUTOR_VERSION); } catch (::apache::thrift::transport::TTransportException& x) { - // sets stop_ flag to true forever, replace with new instance - if (x.getType() == ::apache::thrift::transport::TTransportException::NOT_OPEN) { - recreateOriginExecutor(); - } + // any transport error leaves the concurrent client dead (stop_ set forever) and a late reply + // could still arrive on this connection: replace it now, not on the next call + recreateOriginExecutor(); _return.status.code = 1; _return.status.message = x.what(); @@ -97,10 +96,9 @@ void cs::Executor::getContractMethods(executor::GetContractMethodsResult& _retur origExecutor_->getContractMethods(_return, byteCodeObjects, EXECUTOR_VERSION); } catch (const ::apache::thrift::transport::TTransportException& x) { - // sets stop_ flag to true forever, replace with new instance - if (x.getType() == ::apache::thrift::transport::TTransportException::NOT_OPEN) { - recreateOriginExecutor(); - } + // any transport error leaves the concurrent client dead (stop_ set forever) and a late reply + // could still arrive on this connection: replace it now, not on the next call + recreateOriginExecutor(); _return.status.code = 1; _return.status.message = x.what(); @@ -121,10 +119,9 @@ void cs::Executor::getContractVariables(executor::GetContractVariablesResult& _r origExecutor_->getContractVariables(_return, byteCodeObjects, contractState, EXECUTOR_VERSION); } catch (const ::apache::thrift::transport::TTransportException& x) { - // sets stop_ flag to true forever, replace with new instance - if (x.getType() == ::apache::thrift::transport::TTransportException::NOT_OPEN) { - recreateOriginExecutor(); - } + // any transport error leaves the concurrent client dead (stop_ set forever) and a late reply + // could still arrive on this connection: replace it now, not on the next call + recreateOriginExecutor(); _return.status.code = 1; _return.status.message = x.what(); @@ -145,10 +142,9 @@ void cs::Executor::compileSourceCode(executor::CompileSourceCodeResult& _return, origExecutor_->compileSourceCode(_return, sourceCode, EXECUTOR_VERSION); } catch (::apache::thrift::transport::TTransportException& x) { - // sets stop_ flag to true forever, replace with new instance - if (x.getType() == ::apache::thrift::transport::TTransportException::NOT_OPEN) { - recreateOriginExecutor(); - } + // any transport error leaves the concurrent client dead (stop_ set forever) and a late reply + // could still arrive on this connection: replace it now, not on the next call + recreateOriginExecutor(); _return.status.code = 1; _return.status.message = x.what(); @@ -169,10 +165,9 @@ void cs::Executor::getExecutorBuildVersion(executor::ExecutorBuildVersionResult& origExecutor_->getExecutorBuildVersion(_return, EXECUTOR_VERSION); } catch (::apache::thrift::transport::TTransportException& x) { - // sets stop_ flag to true forever, replace with new instance - if (x.getType() == ::apache::thrift::transport::TTransportException::NOT_OPEN) { - recreateOriginExecutor(); - } + // any transport error leaves the concurrent client dead (stop_ set forever) and a late reply + // could still arrive on this connection: replace it now, not on the next call + recreateOriginExecutor(); _return.status.code = 1; _return.status.message = x.what(); @@ -940,10 +935,9 @@ std::optional cs::Executor::execute(const std origExecutor_->executeByteCode(originExecuteRes.resp, static_cast(accessId), address, smartContractBinary, methodHeader, EXECUTION_TIME, EXECUTOR_VERSION); } catch (::apache::thrift::transport::TTransportException& x) { - // sets stop_ flag to true forever, replace with new instance - if (x.getType() == ::apache::thrift::transport::TTransportException::NOT_OPEN) { - recreateOriginExecutor(); - } + // any transport error leaves the concurrent client dead (stop_ set forever) and a late reply + // could still arrive on this connection: replace it now, not on the next call + recreateOriginExecutor(); if (x.getType() == ::apache::thrift::transport::TTransportException::TIMED_OUT) { originExecuteRes.resp.status.code = cs::error::TimeExpired;