fix: don't hide error on LISTEN channel failure (#3323)

This commit is contained in:
Steve Chavez
2024-03-11 19:56:35 -05:00
committed by GitHub
parent 650249ed29
commit 00f5780415
3 changed files with 22 additions and 12 deletions
+7 -6
View File
@@ -487,15 +487,16 @@ listener appState observer = do
putIsListenerOn appState True
SQL.listen db $ SQL.toPgIdentifier dbChannel
SQL.waitForNotifications handleNotification db
_ ->
die $ "Could not listen for notifications on the " <> dbChannel <> " channel"
Left err -> do
observer $ DBListenerFail dbChannel err
exitFailure
where
handleFinally _ False _ = do
observer DBListenerFailNoRecoverObs
handleFinally dbChannel False err = do
observer $ DBListenerFailNoRecoverObs dbChannel err
killThread (getMainThreadId appState)
handleFinally dbChannel True _ = do
handleFinally dbChannel True err = do
-- if the thread dies, we try to recover
observer $ DBListenerFailRecoverObs dbChannel
observer $ DBListenerFailRecoverObs dbChannel err
putIsListenerOn appState False
-- assume the pool connection was also lost, call the connection worker
connectionWorker appState