Skip to content

Commit 09b1440

Browse files
committed
bin/background-worker: Remove panic behavior
The only cases of our code hitting the `panic!()` in production so far have been because of a read-only Postgres database during database server maintenance. The r2d2 connection pool automatically recovers from this though. In other words: there is no benefit in us panicking after five failures if in all observed instances it would have been sufficient to wait for the database to recover. Since the startup on production takes multiple minutes due to the index repository cloning it seems somewhat bad to restart the whole dyno after just five seconds of database connection issues.
1 parent df5a5a7 commit 09b1440

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/bin/background-worker.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,9 @@ fn main() -> anyhow::Result<()> {
9999

100100
info!("Runner booted, running jobs");
101101

102-
let mut failure_count = 0;
103-
104102
loop {
105-
if let Err(e) = runner.run_all_pending_jobs() {
106-
failure_count += 1;
107-
if failure_count < 5 {
108-
warn!(?failure_count, err = ?e, "Error running jobs -- retrying");
109-
} else {
110-
panic!("Failed to begin running jobs 5 times. Restarting the process");
111-
}
103+
if let Err(err) = runner.run_all_pending_jobs() {
104+
warn!(%err, "Failed to run background jobs");
112105
}
113106
sleep(Duration::from_secs(1));
114107
}

0 commit comments

Comments
 (0)