-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: main
Are you sure you want to change the base?
Conversation
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
@@ -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?, |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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")
}
};
```
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.