Consider schema cache state on the health check #2107
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As suggested in #2092 (comment)
This change does prevent a healthy response in case something like #2024 happens, but only at startup. If the schema cache fails to load after startup, the main app will continue working and the health check will respond accordingly.
The main app failure happens at startup because of:
postgrest/src/PostgREST/App.hs
Lines 203 to 208 in 4f7ee6f
Should we turn the schema cache to Nothing if it fails loading? That would make the main app fail for all requests, I think it's better to leave the schema cache stale in that case, as it happens currently.
Edit: On second thought, I think it'd be better to void the schema cache, otherwise the app will continue running with a stale schema cache and the developers won't know about it.