Skip to content

executor: stop a contract method once its node has closed the connection - #12

Merged
EnzinoBB merged 2 commits into
build/reproducible-1518from
fix/stop-orphan-calls
Oct 30, 2026
Merged

EnzinoBB merged 2 commits into
build/reproducible-1518from
fix/stop-orphan-calls

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

Summary

The node waits executor_receive_timeout (4 s by default) for an answer, records the call as timed out (TimeExpired) and closes the connection; the executor gives the method the execution time the node sends (Consensus::TimeSmartContract, 60 s). A method running past the node's wait went on, holding a CPU, for an answer nobody could read, while the node sent its next calls: with paid calls, executors of the confidants could be kept busy.

  • ClientConnection wraps the server's processor so that each request knows its connection (TSocket).
  • LimitedExecutionMethod waits for the method in slices of 250 ms; between them it peeks the connection (1 ms read on the buffered stream with mark/reset: nothing is consumed). On end of stream the method is stopped exactly as at its limit.

Compatibility: an answer on a closed connection cannot be delivered, so what the node records does not change. With the connection open the code path is the one of build 1518 (the deadline is the same execution time). Unknown transports or any error count as open.

Test plan

  • Node harness (scenario abandoned_call, api: refuse a contract call whose method the executor cannot find node#132): a method running past a 3 s client wait; this branch logs <contract>: the node closed the connection, the call is stopped and answers the next call; 1518 keeps running it
  • Full harness, 1518 against this branch: 0 differing answers
  • Unit tests: the same failures as on the base branch (the external-call tests, and waitCorrectCompleteOfSmartContract, whose 3 ms grace is too short on a loaded machine: it fails 4 times out of 4 on 511d7f7 too)
  • CI

🤖 Generated with Claude Code

The node waits executor_receive_timeout (4 s by default) for an answer, records the call as
timed out and closes the connection; the executor gives the method the execution time the node
sends (60 s). A method that runs past the node's wait went on, holding a CPU, for an answer
nobody could read, and a node sends its next calls meanwhile.

While a method runs, the Thrift thread now looks every 250 ms whether the node closed the
connection of the request (end of stream on it, peeked without consuming anything) and stops
the method as at its limit. An answer on a closed connection cannot be delivered, so what the
node records does not change; with the connection open everything is as before.
@EnzinoBB
EnzinoBB merged commit 35b8166 into build/reproducible-1518 Oct 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant