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

fix: shutdown ordering tasks with sigint #629

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dav1do
Copy link
Contributor

@dav1do dav1do commented Dec 6, 2024

The ordering tasks wouldn't shutdown gracefully and could take forever. Worst case you killed the process and left a lock on the sqlite file and had to go find another pid to kill it. Now they exit with sigint.

could take hours and it wouldn't shutdown with interrupt. if you killed the process you might leave the lock on the sqlite db and need fuser to find and kill the pid to release it
@dav1do dav1do requested review from nathanielc, a team and stbrody as code owners December 6, 2024 18:50
@dav1do dav1do requested review from 3benbox and removed request for a team December 6, 2024 18:50
@@ -1416,7 +1416,9 @@ mod tests {
let sql_pool = SqlitePool::connect_in_memory().await.unwrap();

let metrics = Metrics::register(&mut prometheus_client::registry::Registry::default());
let store = Arc::new(EventService::try_new(sql_pool, true, true, vec![]).await?);
let store = Arc::new(
EventService::try_new(sql_pool, UndeliveredEventReview::Skip, true, vec![]).await?,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this behavior to skip ordering here but I don't think it is necessary for these tests.

@@ -434,8 +436,19 @@ pub async fn run(opts: DaemonOpts) -> Result<()> {
let peer_svc = Arc::new(PeerService::new(sqlite_pool.clone()));
let interest_svc = Arc::new(InterestService::new(sqlite_pool.clone()));
let event_validation = opts.event_validation.unwrap_or(true);
let mut ss = shutdown_signal.resubscribe();
let event_svc = Arc::new(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this whole PR could probably be redone as simply this (which I didn't think of for some reason)... piping it down could allow for a chance to exit gracefully and clean up, but it's more or less implemented like this currently just lower

    let mut ss = shutdown_signal.resubscribe();
    let event_svc = tokio::select! {
        svc = EventService::try_new(sqlite_pool.clone(), true, event_validation, rpc_providers) => {
            Arc::new(svc?)
        }
        _ = ss.recv() => {
            bail!("received shutdown signal before startup tasks finished")
        }
    };
    ```

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