feat: Add compatibility with connection poolers on transaction mode
Update the hasql-transaction library to version 1.0.1 Add hints and kill thread at configuration read when using incompatible pooling modes: statement pooling and transaction pooling with prepared statements enabled.
This commit is contained in:
@@ -151,7 +151,8 @@ loadSchemaCache :: AppState -> IO SCacheStatus
|
||||
loadSchemaCache appState = do
|
||||
AppConfig{..} <- AppState.getConfig appState
|
||||
result <-
|
||||
P.use (AppState.getPool appState) . HT.transaction HT.ReadCommitted HT.Read $
|
||||
let transaction = if configDbPreparedStatements then HT.transaction else HT.unpreparedTransaction in
|
||||
P.use (AppState.getPool appState) . transaction HT.ReadCommitted HT.Read $
|
||||
queryDbStructure (toList configDbSchemas) configDbExtraSearchPath configDbPreparedStatements
|
||||
case result of
|
||||
Left e -> do
|
||||
@@ -159,12 +160,10 @@ loadSchemaCache appState = do
|
||||
err = PgError False e
|
||||
putErr = AppState.logWithZTime appState . toS $ errorPayload err
|
||||
case checkIsFatal err of
|
||||
Just _ -> do
|
||||
Just hint -> do
|
||||
AppState.logWithZTime appState "A fatal error ocurred when loading the schema cache"
|
||||
putErr
|
||||
AppState.logWithZTime appState $
|
||||
"This is probably a bug in PostgREST, please report it at "
|
||||
<> "https://github.com/PostgREST/postgrest/issues"
|
||||
AppState.logWithZTime appState hint
|
||||
return SCFatalFail
|
||||
Nothing -> do
|
||||
AppState.logWithZTime appState "An error ocurred when loading the schema cache"
|
||||
@@ -229,12 +228,21 @@ reReadConfig startingUp appState = do
|
||||
AppConfig{..} <- AppState.getConfig appState
|
||||
dbSettings <-
|
||||
if configDbConfig then do
|
||||
qDbSettings <- queryDbSettings $ AppState.getPool appState
|
||||
qDbSettings <- queryDbSettings (AppState.getPool appState) configDbPreparedStatements
|
||||
case qDbSettings of
|
||||
Left e -> do
|
||||
AppState.logWithZTime appState $
|
||||
"An error ocurred when trying to query database settings for the config parameters:\n"
|
||||
<> show e
|
||||
let
|
||||
err = PgError False e
|
||||
putErr = AppState.logWithZTime appState . toS $ errorPayload err
|
||||
AppState.logWithZTime appState
|
||||
"An error ocurred when trying to query database settings for the config parameters"
|
||||
case checkIsFatal err of
|
||||
Just hint -> do
|
||||
putErr
|
||||
AppState.logWithZTime appState hint
|
||||
killThread (AppState.getMainThreadId appState)
|
||||
Nothing -> do
|
||||
AppState.logWithZTime appState $ show e
|
||||
pure []
|
||||
Right x -> pure x
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user