-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix PGRST002 errors not logging the JSON messages and reloading the schema unnecessarily on startup #4367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
319f1a5
to
794f22c
Compare
794f22c
to
b1a49bd
Compare
b1a49bd
to
c30a9d0
Compare
39886b2
to
a2bb823
Compare
src/PostgREST/App.hs
Outdated
-- the connWorker is done. However it won't launch the connWorker if | ||
-- the schema cache was not loaded beforehand, i.e. on startup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please elaborate more on that comment. It says it does something but not why (because it's wasteful to rerun the scache queries again if it's not completed anyway?)
You can also link to #3704. The most detail the better because this part is complex and I'm not sure if it's all covered on tests.
a2bb823
to
6f2993a
Compare
test/io/test_io.py
Outdated
def test_pgrst_log_503_no_schema_cache_startup_error_to_stderr( | ||
defaultenv, metapostgrest | ||
): | ||
"Should log the 503 error message when the schema cache is not loaded on startup and not reload the schema cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix reloading the Schema Cache unnecessarily on a
PGRST002
error by @laurenceisla in #4367
Is this proving the above too? If so, why not use https://docs.postgrest.org/en/v13/references/observability.html#pgrst-schema-cache-loads-total instead? It would be much more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this proving the above too?
Yes
If so, why not use https://docs.postgrest.org/en/v13/references/observability.html#pgrst-schema-cache-loads-total instead? It would be much more clear.
Oh, forgot about that metric, it's much clearer now! I separated it in another test (can confirm that it fails in main
cause it returns 2.0
reloads there).
test/io/test_io.py
Outdated
def test_pgrst_log_503_no_schema_cache_startup_error_to_stderr( | ||
defaultenv, metapostgrest | ||
): | ||
"Should log the 503 error message when the schema cache is not loaded on startup and not reload the schema cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This second part is not too clear, I'd suggest rephrasing or splitting into two tests
"Should log the 503 error message when the schema cache is not loaded on startup and not reload the schema cache" | |
"Should log the 503 error message when the schema cache is not loaded on startup |
6f2993a
to
4ee98d7
Compare
It happens right after the configuration is loaded and before the schema cache is queried.
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.
4ee98d7
to
95720c5
Compare
Closes #4129 as mentioned in the revision #4129 (comment).