fix: reloading the Schema Cache unnecessarily on a PGRST002 error
When 503 errors happen if the Schema Cache is empty, it should not retrigger the connection worker since there's no Schema Cache loaded yet.
This commit is contained in:
@@ -1892,6 +1892,28 @@ def test_log_error_when_empty_schema_cache_on_startup_to_stderr(defaultenv):
|
||||
assert any(log_err_message in line for line in output_start)
|
||||
|
||||
|
||||
def test_no_double_schema_cache_reload_on_empty_schema(defaultenv):
|
||||
"Should only load the schema cache once on a 503 error when there's an empty schema cache on startup"
|
||||
|
||||
env = {
|
||||
**defaultenv,
|
||||
"PGRST_INTERNAL_SCHEMA_CACHE_QUERY_SLEEP": "300",
|
||||
}
|
||||
|
||||
with run(env=env, port=freeport(), wait_for_readiness=False) as postgrest:
|
||||
postgrest.wait_until_scache_starts_loading()
|
||||
|
||||
response = postgrest.session.get("/projects")
|
||||
assert response.status_code == 503
|
||||
|
||||
# Should wait enough time to load the schema cache twice to guarantee that the test is valid
|
||||
time.sleep(1)
|
||||
|
||||
response = postgrest.admin.get("/metrics")
|
||||
assert response.status_code == 200
|
||||
assert 'pgrst_schema_cache_loads_total{status="SUCCESS"} 1.0' in response.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("level", ["crit", "error", "warn", "info", "debug"])
|
||||
def test_log_pool_req_observation(level, defaultenv):
|
||||
"PostgREST should log PoolRequest and PoolRequestFullfilled observation when log-level=debug"
|
||||
|
||||
Reference in New Issue
Block a user