Your one-stop-cake-shop for everything Freshly Baked has to offer

fix(m): wait for postgres connection #153

merged opened by a.starrysky.fyi targeting main from private/minion/push-tuxqlnlmuxol

I woke up this morning to a dead menu instance and the following backtrace:

Jan 05 04:46:24 teal menu-start[1351]: thread 'main' (1351) panicked at src/main.rs:173:6:
Jan 05 04:46:24 teal menu-start[1351]: Failed to connect to database defined in $DATABASE_URL: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })
Jan 05 04:46:24 teal menu-start[1351]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It seems like this is because, when teal restarted, postgresql hadn't created a socket by the time menu connected. Restarting menu after the fact let it run Just Fine. Adding some retries should stop this problem from coming up...

...a proper solution is probably to fix whatever decides that postgresql is ready in packetmix, but this is much easier to locate and implement

Labels

None yet.

requested-reviewers

None yet.

approved

None yet.

tested-working

None yet.

rejected

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:uuyqs6y3pwtbteet4swt5i5y/sh.tangled.repo.pull/3mbnxawpmek22
+5 -2
Interdiff #0 โ†’ #1
+5 -2
menu/src/main.rs
··· 170 async fn main() { 171 let mut connection = { 172 let mut maybe_connection; 173 - for _ in 0..3 { 174 maybe_connection = PgConnection::connect( 175 env::var("DATABASE_URL") 176 .expect( ··· 180 ) 181 .await; 182 183 - if maybe_connection.is_ok() { 184 break; 185 } 186
··· 170 async fn main() { 171 let mut connection = { 172 let mut maybe_connection; 173 + let mut tries = 3; 174 + loop { 175 + // We can't use a for loop here as rust doesn't know it will run at least once... 176 + tries -= 1; 177 maybe_connection = PgConnection::connect( 178 env::var("DATABASE_URL") 179 .expect( ··· 183 ) 184 .await; 185 186 + if maybe_connection.is_ok() || tries == 0 { 187 break; 188 } 189

History

2 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
fix(m): wait for postgres connection
expand 0 comments
pull request successfully merged
1 commit
expand
fix(m): wait for postgres connection
expand 0 comments