Merge pull request #7973 from penpot/niwinz-staging-worker-scheduler

🐛 Fix incorrect redis connection error handling
This commit is contained in:
Alejandro Alonso 2025-12-12 13:23:49 +01:00 committed by GitHub
commit 82d3e2024e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 24 deletions

View File

@ -137,33 +137,34 @@ RETURNING task.id, task.queue")
::wait))) ::wait)))
(run-batch [] (run-batch []
(let [rconn (rds/connect cfg)] (try
(try (let [rconn (rds/connect cfg)]
(-> cfg (try
(assoc ::rds/conn rconn) (-> cfg
(db/tx-run! run-batch')) (assoc ::rds/conn rconn)
(db/tx-run! run-batch'))
(finally
(.close ^AutoCloseable rconn))))
(catch InterruptedException cause (catch InterruptedException cause
(throw cause)) (throw cause))
(catch Exception cause
(cond
(rds/exception? cause)
(do
(l/wrn :hint "redis exception (will retry in an instant)" :cause cause)
(px/sleep timeout))
(db/sql-exception? cause) (catch Exception cause
(do (cond
(l/wrn :hint "database exception (will retry in an instant)" :cause cause) (rds/exception? cause)
(px/sleep timeout)) (do
(l/wrn :hint "redis exception (will retry in an instant)" :cause cause)
(px/sleep timeout))
:else (db/sql-exception? cause)
(do (do
(l/err :hint "unhandled exception (will retry in an instant)" :cause cause) (l/wrn :hint "database exception (will retry in an instant)" :cause cause)
(px/sleep timeout)))) (px/sleep timeout))
(finally :else
(.close ^AutoCloseable rconn))))) (do
(l/err :hint "unhandled exception (will retry in an instant)" :cause cause)
(px/sleep timeout))))))
(dispatcher [] (dispatcher []
(l/inf :hint "started") (l/inf :hint "started")
@ -176,7 +177,7 @@ RETURNING task.id, task.queue")
(catch InterruptedException _ (catch InterruptedException _
(l/trc :hint "interrupted")) (l/trc :hint "interrupted"))
(catch Throwable cause (catch Throwable cause
(l/err :hint " unexpected exception" :cause cause)) (l/err :hint "unexpected exception" :cause cause))
(finally (finally
(l/inf :hint "terminated"))))] (l/inf :hint "terminated"))))]