feat: use hasql-pool-0.9, add db-pool-max-lifetime (fixes #2638)

- db-pool-acquisition-timeout is no longer optional, defaults to 10s
- new option db-pool-max-lifetime limits the maximal lifetime of a
  postgresql connection, defaults to 30m
This commit is contained in:
Robert Vollmert
2023-04-12 12:49:36 -05:00
committed by steve-chavez
parent b869dd7be9
commit f26cdd5151
20 changed files with 83 additions and 23 deletions
+2 -1
View File
@@ -5,7 +5,8 @@ db-extra-search-path = "public"
db-max-rows = 1000
db-plan-enabled = false
db-pool = 10
db-pool-acquisition-timeout = ""
db-pool-acquisition-timeout = 10
db-pool-max-lifetime = 1800
db-pre-request = "check_alias"
db-prepared-statements = true
db-root-spec = "open_alias"
@@ -5,7 +5,8 @@ db-extra-search-path = "public"
db-max-rows = ""
db-plan-enabled = false
db-pool = 10
db-pool-acquisition-timeout = ""
db-pool-acquisition-timeout = 10
db-pool-max-lifetime = 1800
db-pre-request = ""
db-prepared-statements = false
db-root-spec = ""
@@ -5,7 +5,8 @@ db-extra-search-path = "public"
db-max-rows = ""
db-plan-enabled = false
db-pool = 10
db-pool-acquisition-timeout = ""
db-pool-acquisition-timeout = 10
db-pool-max-lifetime = 1800
db-pre-request = ""
db-prepared-statements = false
db-root-spec = ""
+2 -1
View File
@@ -5,7 +5,8 @@ db-extra-search-path = "public"
db-max-rows = ""
db-plan-enabled = false
db-pool = 10
db-pool-acquisition-timeout = ""
db-pool-acquisition-timeout = 10
db-pool-max-lifetime = 1800
db-pre-request = ""
db-prepared-statements = true
db-root-spec = ""
@@ -5,7 +5,8 @@ db-extra-search-path = "public,extensions,other"
db-max-rows = 100
db-plan-enabled = true
db-pool = 1
db-pool-acquisition-timeout = 10
db-pool-acquisition-timeout = 30
db-pool-max-lifetime = 3600
db-pre-request = "test.other_custom_headers"
db-prepared-statements = false
db-root-spec = "other_root"
@@ -5,7 +5,8 @@ db-extra-search-path = "public,extensions,private"
db-max-rows = 1000
db-plan-enabled = true
db-pool = 1
db-pool-acquisition-timeout = 10
db-pool-acquisition-timeout = 30
db-pool-max-lifetime = 3600
db-pre-request = "test.custom_headers"
db-prepared-statements = false
db-root-spec = "root"
+2 -1
View File
@@ -5,7 +5,8 @@ db-extra-search-path = "public,test"
db-max-rows = 1000
db-plan-enabled = true
db-pool = 1
db-pool-acquisition-timeout = 10
db-pool-acquisition-timeout = 30
db-pool-max-lifetime = 3600
db-pre-request = "please_run_fast"
db-prepared-statements = false
db-root-spec = "openapi_v3"
+2 -1
View File
@@ -5,7 +5,8 @@ db-extra-search-path = "public"
db-max-rows = ""
db-plan-enabled = false
db-pool = 10
db-pool-acquisition-timeout = ""
db-pool-acquisition-timeout = 10
db-pool-max-lifetime = 1800
db-pre-request = ""
db-prepared-statements = true
db-root-spec = ""
+2 -1
View File
@@ -7,7 +7,8 @@ PGRST_DB_EXTRA_SEARCH_PATH: public, test
PGRST_DB_MAX_ROWS: 1000
PGRST_DB_PLAN_ENABLED: true
PGRST_DB_POOL: 1
PGRST_DB_POOL_ACQUISITION_TIMEOUT: 10
PGRST_DB_POOL_ACQUISITION_TIMEOUT: 30
PGRST_DB_POOL_MAX_LIFETIME: 3600
PGRST_DB_PREPARED_STATEMENTS: false
PGRST_DB_PRE_REQUEST: please_run_fast
PGRST_DB_ROOT_SPEC: openapi_v3
+2 -1
View File
@@ -5,7 +5,8 @@ db-extra-search-path = "public, test"
db-max-rows = 1000
db-plan-enabled = true
db-pool = 1
db-pool-acquisition-timeout = 10
db-pool-acquisition-timeout = 30
db-pool-max-lifetime = 3600
db-pre-request = "please_run_fast"
db-prepared-statements = false
db-root-spec = "openapi_v3"
+1 -1
View File
@@ -64,7 +64,7 @@ import qualified Feature.RpcPreRequestGucsSpec
main :: IO ()
main = do
pool <- P.acquire 3 Nothing $ toUtf8 $ configDbUri testCfg
pool <- P.acquire 3 10 60 $ toUtf8 $ configDbUri testCfg
actualPgVersion <- either (panic . show) id <$> P.use pool queryPgVersion
+2 -1
View File
@@ -82,7 +82,8 @@ baseCfg = let secret = Just $ encodeUtf8 "reallyreallyreallyreallyverysafe" in
, configDbMaxRows = Nothing
, configDbPlanEnabled = False
, configDbPoolSize = 10
, configDbPoolAcquisitionTimeout = Nothing
, configDbPoolAcquisitionTimeout = 10
, configDbPoolMaxLifetime = 1800
, configDbPreRequest = Just $ QualifiedIdentifier "test" "switch_role"
, configDbPreparedStatements = True
, configDbRootSpec = Nothing