feat(trin-execution): allow ctrl+c to immediately stop execution #1451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was wrong?
Using Ctrl+C to stop trin_execution can take a lot of time, partially due to committing to db (which can't be avoided), and partially because execution doesn't stop until next checkpoint (which can take another 30 min).
How was it fixed?
Refactor how TrinExecution executes blocks (built on top of #1450).
Instead of executing until the first commit (which can come early), it will now execute all the way to the provided block but it accepts
stop_signal
receiver. When stop signal is received, it will commit and return.Note: Tested it locally (around block 6'000'000).
Future ideas
We can speed up the shutdown by abandoning changes that are in memory (by not committing anything), but we would have the same problem that is described in #1440.
Even if implemented, it's questionable if this is desired behavior, so maybe we would need a flag that controls whether to commit on ctrl+c or not.
To-Do