fix: listener silent fail on replica
Update hasql-notifications to include the fix on https://github.com/diogob/hasql-notifications/issues/24. Which now reveals the following error: ``` $ postgrest-with-postgresql-16 --replica -f test/spec/fixtures/load.sql postgrest-run 17/May/2024:18:35:38 -0500: Successfully connected to PostgreSQL 16.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.2.0, 64-bit 17/May/2024:18:35:38 -0500: Could not listen for notifications on the "pgrst" channel. ERROR: cannot execute LISTEN during recovery 17/May/2024:18:35:38 -0500: Retrying listening for notifications... ``` This is still not good because the LISTEN channel will be retried forever without a backoff.
This commit is contained in:
committed by
Steve Chavez
parent
aa75412932
commit
756aad7827
@@ -542,23 +542,25 @@ listener appState@AppState{stateObserver=observer, stateMainThreadId=mainThreadI
|
||||
dbOrError <- acquire $ toUtf8 (addFallbackAppName prettyVersion configDbUri)
|
||||
case dbOrError of
|
||||
Right db -> do
|
||||
observer $ DBListenerStart dbChannel
|
||||
SQL.listen db $ SQL.toPgIdentifier dbChannel
|
||||
observer $ DBListenStart dbChannel
|
||||
SQL.waitForNotifications handleNotification db
|
||||
|
||||
Left err -> do
|
||||
observer $ DBListenerFail dbChannel err
|
||||
observer $ DBListenFail dbChannel (Left err)
|
||||
exitFailure
|
||||
where
|
||||
handleFinally dbChannel False err = do
|
||||
observer $ DBListenerFailRecoverObs False dbChannel err
|
||||
observer $ DBListenFail dbChannel (Right err)
|
||||
killThread mainThreadId
|
||||
handleFinally dbChannel True err = do
|
||||
-- if the thread dies, we try to recover
|
||||
observer $ DBListenerFailRecoverObs True dbChannel err
|
||||
observer $ DBListenFail dbChannel (Right err)
|
||||
-- assume the pool connection was also lost, call the connection worker
|
||||
connectionWorker appState
|
||||
|
||||
-- retry the listener
|
||||
observer DBListenRetry
|
||||
listener appState conf
|
||||
|
||||
handleNotification channel msg =
|
||||
|
||||
Reference in New Issue
Block a user