fix: Do not clear the schema cache during retries

retryingSchemaCacheLoad should not clear existing schema cache upon failure - there is no reason to do that. If there is a communication issue with the database server or db is down, clients are going to get 502 anyway. If it was a glitch when loading the schema cache - the clients are going to use old (stale) schema cache for some time until next retry re-loads it successfully.
This commit is contained in:
Michał Kłeczek
2026-06-11 13:14:37 -05:00
committed by Steve Chavez
parent e9a016670f
commit 54430c3a2c
3 changed files with 2 additions and 2 deletions
+1
View File
@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file. From versio
- Shutdown should wait for in flight requests by @mkleczek in #4702 - Shutdown should wait for in flight requests by @mkleczek in #4702
- Remove automatic transaction retries on `40001 (serialization_failure)` errors to prevent replication lag by @laurenceisla in #3673 - Remove automatic transaction retries on `40001 (serialization_failure)` errors to prevent replication lag by @laurenceisla in #3673
- Fix unexpected results when embedding and filtering the same table more than once by @laurenceisla in #4075 - Fix unexpected results when embedding and filtering the same table more than once by @laurenceisla in #4075
- If the schema cache fails to reload, PostgREST will no longer stop serving requests and will continue doing so in a "best effort" basis by @mkleczek in #4873 #4869
### Changed ### Changed
-1
View File
@@ -347,7 +347,6 @@ retryingSchemaCacheLoad appState@AppState{stateObserver=observer, stateMainThrea
case result of case result of
Left e -> do Left e -> do
markSchemaCachePending appState markSchemaCachePending appState
putSchemaCache appState Nothing
observer $ SchemaCacheErrorObs configDbSchemas configDbExtraSearchPath e observer $ SchemaCacheErrorObs configDbSchemas configDbExtraSearchPath e
return Nothing return Nothing
+1 -1
View File
@@ -763,7 +763,7 @@ def test_admin_ready_includes_schema_cache_state(defaultenv, metapostgrest):
assert response.status_code == 503 assert response.status_code == 503
response = postgrest.session.get("/projects", timeout=1) response = postgrest.session.get("/projects", timeout=1)
assert response.status_code == 503 assert response.status_code == 200
reset_statement_timeout(metapostgrest, role) reset_statement_timeout(metapostgrest, role)