fix: retry connection on failed schema cache load (#1685)

Retry the connection when the
"Failed to load the schema cache" error happens.

Also die if the schema cache query has a syntax error.
This commit is contained in:
Steve Chavez
2020-12-09 14:20:00 -05:00
committed by GitHub
parent 11d62a8010
commit ebd474a7e6
3 changed files with 39 additions and 13 deletions
+4 -2
View File
@@ -115,7 +115,7 @@ compressedRel rel =
(_, _, _) ->
mempty
data PgError = PgError Authenticated P.UsageError
data PgError = PgError Authenticated P.UsageError deriving Show
type Authenticated = Bool
instance PgrstError PgError where
@@ -216,7 +216,9 @@ checkIsFatal (PgError _ (P.ConnectionError e))
| isAuthFailureMessage = Just $ toS failureMessage
| otherwise = Nothing
where isAuthFailureMessage = "FATAL: password authentication failed" `isPrefixOf` toS failureMessage
failureMessage = fromMaybe "" e
failureMessage = fromMaybe mempty e
-- Chek for a syntax error(42601 is the pg code). This would mean the error is on our part somehow, so we treat it as fatal.
checkIsFatal (PgError _ (P.SessionError (H.QueryError _ _ (H.ResultError (H.ServerError "42601" e _ _))))) = Just $ toS e
checkIsFatal _ = Nothing
+7
View File
@@ -560,6 +560,13 @@ data ConnectionStatus
| FatalConnectionError Text
deriving (Eq, Show)
-- | Schema cache status
data SCacheStatus
= SCLoaded
| SCOnRetry
| SCFatalFail
deriving (Eq, Show)
data LogLevel = LogCrit | LogError | LogWarn | LogInfo deriving (Eq)
instance Show LogLevel where