Skip to content

Commit 4d6a87d

Browse files
committed
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.
1 parent 243bbb1 commit 4d6a87d

4 files changed

Lines changed: 5 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. From versio
2121
- Shutdown should wait for in flight requests by @mkleczek in #4702
2222
- Remove automatic transaction retries on `40001 (serialization_failure)` errors to prevent replication lag by @laurenceisla in #3673
2323
- Fix unexpected results when embedding and filtering the same table more than once by @laurenceisla in #4075
24+
- PostgREST no longer returns voids schema cache during loading retries by @mkleczek in #4873 #4869
2425

2526

2627
### Changed

src/PostgREST/AppState.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ retryingSchemaCacheLoad appState@AppState{stateObserver=observer, stateMainThrea
347347
case result of
348348
Left e -> do
349349
markSchemaCachePending appState
350-
putSchemaCache appState Nothing
351350
observer $ SchemaCacheErrorObs configDbSchemas configDbExtraSearchPath e
352351
return Nothing
353352

test/io/fixtures/roles.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ GRANT
1414
postgrest_test_serializable, postgrest_test_repeatable_read,
1515
postgrest_test_w_superuser_settings TO :"PGUSER";
1616

17+
GRANT postgrest_test_anonymous TO timeout_authenticator;
18+
1719
ALTER ROLE :"PGUSER" SET pgrst.db_anon_role = 'postgrest_test_anonymous';
1820
ALTER ROLE postgrest_test_serializable SET default_transaction_isolation = 'serializable';
1921
ALTER ROLE postgrest_test_repeatable_read SET default_transaction_isolation = 'REPEATABLE READ';

test/io/test_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def test_admin_ready_includes_schema_cache_state(defaultenv, metapostgrest):
745745
env = {
746746
**defaultenv,
747747
"PGUSER": role,
748-
"PGRST_DB_ANON_ROLE": role,
748+
"PGRST_DB_ANON_ROLE": "postgrest_test_anonymous",
749749
"PGRST_INTERNAL_SCHEMA_CACHE_QUERY_SLEEP": "500",
750750
}
751751

@@ -763,7 +763,7 @@ def test_admin_ready_includes_schema_cache_state(defaultenv, metapostgrest):
763763
assert response.status_code == 503
764764

765765
response = postgrest.session.get("/projects", timeout=1)
766-
assert response.status_code == 503
766+
assert response.status_code == 200
767767

768768
reset_statement_timeout(metapostgrest, role)
769769

0 commit comments

Comments
 (0)