Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(trin-execution): allow ctrl+c to immediately stop execution #1451

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

morph-dev
Copy link
Collaborator

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

@morph-dev morph-dev requested a review from KolbyML September 14, 2024 14:42
@morph-dev morph-dev self-assigned this Sep 14, 2024
@KolbyML
Copy link
Member

KolbyML commented Sep 14, 2024

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.

#1440 (comment) as said in my comment here we would want to switch to an ACID compliment database.

We want ctrl+c to instantly shutdown the node, as we want to prevent the Operating System from force killing trin-execution on shutdown, which could corrupt the database. Switching to an ACID compliment database, resolves this class of problems to my knowledge. We should be able to shutdown even if we are in the middle of writing to the database, as we could set it to only consider the writes valid when we are done them (like the full set of commit class writes).

ACID compliment database should also protect the user from power outages, force kills, etc.

Executing blocks is time consuming, RocksDB sucks in that regard because you are way more likely to get your database corrupted which sucks. LMDB or MXDB solves a lot of these problems

Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@KolbyML
Copy link
Member

KolbyML commented Sep 14, 2024

ACID
In computer science, ACID is a set of properties of database 
transactions intended to guarantee data validity despite errors, 
power failures, and other mishaps. In the context of databases, 
a sequence of database operations that satisfies the ACID 
properties is called a transaction.

This solves that whole* class of problems

@morph-dev morph-dev merged commit 67ac2e3 into ethereum:master Sep 15, 2024
9 checks passed
@morph-dev morph-dev deleted the stop_signal branch September 15, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants