divviup / divviup-api

Divvi Up Control Plane
https://divviup.org
Mozilla Public License 2.0
4 stars 1 forks source link

Database errors on startup stops queue worker #416

Open divergentdave opened 1 year ago

divergentdave commented 1 year ago

I brought divviup-api up before the database schema was ready, and the following panic happened in the queue worker task.

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Query(SqlxError(Database(PgDatabaseError { severity: Error, code: "42P01", message: "relation \"queue\" does not exist", detail: None, hint: None, position: Some(Original(253)), where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("parse_relation.c"), line: Some(1384), routine: Some("parserOpenTable") })))', src/queue.rs:195:57

This was likely from the schedule_recurring_tasks_if_needed() call. The process continued to run, but asynchronous tasks did not make any progress.

jbr commented 1 year ago

What should we do? Probably exit with an error?

divergentdave commented 1 year ago

I think exiting with an error would be good in the case of schedule_recurring_tasks_if_needed(), since that only has to happen once at startup IIUC. The worker task should otherwise keep running if it gets errors during steady-state operation, but I think we're okay on that front from a quick skim.