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

Terminate gracefully #1987

Open
majecty opened this issue Aug 26, 2020 · 1 comment
Open

Terminate gracefully #1987

majecty opened this issue Aug 26, 2020 · 1 comment

Comments

@majecty
Copy link
Contributor

majecty commented Aug 26, 2020

The current way of terminating Foundry is to drop all resources at the end of run_node function.
Since we didn't care about the order of drop, sometimes Foundry panics in the termination process since other resources are dropped without expectation.
In the worst case, the database can be corrupted in the termination process.

@majecty
Copy link
Contributor Author

majecty commented Aug 26, 2020

There are four types of entities that should be terminated.
This is the termination order.

  1. Snapshot service
    Since other code does not depend on the snapshot service. I will terminate the snapshot service first.

  2. Network
    By terminating the network, Foundry will not receive any packet from the network. All packet sending will be ignored after termination.

  3. Shutdown client, miner, scheme
    They are main threads that doing consensus, creating a block, reading, and writing state. They depends on each other. Terminating them looks difficult. My plan is below:

    3.0. The network was terminated before.
    3.1. Make consensus algorithm stop. It will not send any request to the client or miner.
    3.2. Waits until client and miner finishing their works(like verifying blocks or creating blocks)
    3.3. If there is no work to client, miner, and tendermint, drop them at the same time.

  4. Utilities
    There are db, timer_loop, logger, and account provider. They are used by the client, miner, and engine(scheme). Since they are terminated before, we can terminate utilities safely.

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

No branches or pull requests

1 participant