Skip to content

Conversation

laurenceisla
Copy link
Member

Closes #4129 as mentioned in the revision #4129 (comment).

@laurenceisla laurenceisla changed the title Fix 503 errors not logging the JSON messages and reloading the schema unnecessarily on startup Fix PGRST002 errors not logging the JSON messages and reloading the schema unnecessarily on startup Oct 8, 2025
@laurenceisla laurenceisla marked this pull request as ready for review October 8, 2025 06:20
@laurenceisla laurenceisla force-pushed the fix/startup-503-errs branch 2 times, most recently from 39886b2 to a2bb823 Compare October 15, 2025 01:35
Comment on lines 114 to 115
-- the connWorker is done. However it won't launch the connWorker if
-- the schema cache was not loaded beforehand, i.e. on startup.
Copy link
Member

@steve-chavez steve-chavez Oct 16, 2025

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.

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"
Copy link
Member

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.

Copy link
Member Author

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).

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"
Copy link
Member

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

Suggested change
"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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Requests are rejected immediately when loading the Schema Cache on startup

2 participants