test: Prevent test_admin_ready_includes_schema_cache_state from timing out
By increasing the delays in this test by factor 400x, postgrest will not swamp pg with connection retries after the failed schema cache anymore. This would happen because there is no backoff included after fatal errors. Once it does, the io tests hang indefinitely in CI.
This commit is contained in:
committed by
Wolfgang Walther
parent
e96e16fa27
commit
747c78f6f4
@@ -145,6 +145,9 @@ type SqlQuery = ByteString
|
||||
|
||||
querySchemaCache :: AppConfig -> SQL.Transaction SchemaCache
|
||||
querySchemaCache AppConfig{..} = do
|
||||
_ <-
|
||||
let sleepCall = SQL.Statement "select pg_sleep($1 / 1000.0)" (param HE.int4) HD.noResult prepared in
|
||||
whenJust configInternalSCSleep (`SQL.statement` sleepCall) -- only used for testing
|
||||
SQL.sql "set local schema ''" -- This voids the search path. The following queries need this for getting the fully qualified name(schema.name) of every db object
|
||||
pgVer <- SQL.statement mempty $ pgVersionStatement prepared
|
||||
tabs <- SQL.statement schemas $ allTables pgVer prepared
|
||||
@@ -155,9 +158,6 @@ querySchemaCache AppConfig{..} = do
|
||||
reps <- SQL.statement schemas $ dataRepresentations prepared
|
||||
mHdlers <- SQL.statement schemas $ mediaHandlers pgVer prepared
|
||||
tzones <- SQL.statement mempty $ timezones prepared
|
||||
_ <-
|
||||
let sleepCall = SQL.Statement "select pg_sleep($1)" (param HE.int4) HD.noResult prepared in
|
||||
whenJust configInternalSCSleep (`SQL.statement` sleepCall) -- only used for testing
|
||||
|
||||
let tabsWViewsPks = addViewPrimaryKeys tabs keyDeps
|
||||
rels = addInverseRels $ addM2MRels tabsWViewsPks $ addViewM2OAndO2ORels keyDeps m2oRels
|
||||
|
||||
+8
-5
@@ -710,20 +710,23 @@ def test_admin_ready_includes_schema_cache_state(defaultenv, metapostgrest):
|
||||
**defaultenv,
|
||||
"PGUSER": role,
|
||||
"PGRST_DB_ANON_ROLE": role,
|
||||
"PGRST_INTERNAL_SCHEMA_CACHE_SLEEP": "500",
|
||||
}
|
||||
|
||||
with run(env=env) as postgrest:
|
||||
# make it impossible to load the schema cache, by setting statement timeout to 1ms
|
||||
set_statement_timeout(metapostgrest, role, 1)
|
||||
# The schema cache query takes at least 500ms, due do PGRST_INTERNAL_SCHEMA_CACHE_SLEEP above.
|
||||
# Make it impossible to load the schema cache, by setting statement timeout to 400ms.
|
||||
set_statement_timeout(metapostgrest, role, 400)
|
||||
|
||||
# force a reconnection so the new role setting is picked up
|
||||
postgrest.process.send_signal(signal.SIGUSR1)
|
||||
sleep_until_postgrest_scache_reload()
|
||||
# wait 600ms to finish schema cache reload attempt
|
||||
time.sleep(0.6)
|
||||
|
||||
response = postgrest.admin.get("/ready")
|
||||
response = postgrest.admin.get("/ready", timeout=1)
|
||||
assert response.status_code == 503
|
||||
|
||||
response = postgrest.session.get("/projects")
|
||||
response = postgrest.session.get("/projects", timeout=1)
|
||||
assert response.status_code == 503
|
||||
|
||||
reset_statement_timeout(metapostgrest, role)
|
||||
|
||||
Reference in New Issue
Block a user