chore(flags): add retries to is_postgres_connected_check for flag matching paths #26708
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.
Problem
We're still trying to root cause the recent spike in
healthcheck_failed
flag evaluation errors (conversation here https://posthog.slack.com/archives/C0185UNBSJZ/p1733369640212279), but for the short term this change will require 3 straightSELECT 1
failures before determining PG to be down when during flag matching 🩹We see in Loki logs that this healthcheck is often failing with
django.db.utils.OperationalError: consuming input failed: query_wait_timeout server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
, especially when the decide request is interacting with the PG writer.We've also identified some over-reporting of
healthcheck_failed
when write paths fail, but short-circuiting other requests would only use read replicas. This will be addressed in a follow up PRChanges
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Hitting decide locally works as expected and with
"errorsWhileComputingFlags": false,