Repository navigation
Fall back to Postgres when the Redis breach cache read fails (mntor-5378) - #6829
Merged
Merged
Conversation
Collaborator
Author
There was a problem hiding this comment.
big take away here is we've separated out the three failures into three separate logs we can more easily trace. we can make these metrics in a future effort
Collaborator
Author
There was a problem hiding this comment.
Just some simple update to our documentation now that we made a change to the flow of data when Redis is down.
Collaborator
Author
There was a problem hiding this comment.
This file is being added as the original src/app/functions/server/getBreaches.ts had no tests
getAllBreachesFromDb swallowed a Redis fault and returned []. getBreaches() reads that as "the breaches table is empty" and answers by fetching the whole catalogue from HIBP and re-upserting it, per request.
The single try wrapped the cache read, the Postgres read and the cache write, so all three failures logged "Failed to read breaches from redis" and all three landed in the same fallback. A Postgres timeout was therefore reported as a Redis fault and then re-queried.
GregHilstonMozilla
force-pushed
the
mntor-5378
branch
from
September 8, 2026 16:29
d66c81d to
7095d92
Compare
GregHilstonMozilla
marked this pull request as ready for review
September 8, 2026 16:29
joeherm
approved these changes
Sep 8, 2026
joeherm
left a comment
Collaborator
There was a problem hiding this comment.
This looks great. Thanks for adding test cases for all the scenarios.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
References:
Jira: MNTOR-5378
Incident doc: 2026-09-03 Monitor Website Unresponsive
Description
getAllBreachesFromDb()wrapped the cache read, the Postgres read and the cache write in onetry, and returned[]from the sharedcatch. Two things fell out of that.A Redis fault surfaced as an empty list, and
getBreaches()reads an empty list as "the breaches table is empty", so it answered with a full HIBP fetch plus upsert. Since it holds no in-memory cache, that ran on every request. A Postgres timeout was also reported asFailed to read breaches from redis, then re-queried against the pool that had just timed out.Split into three independent steps, each with its own
tryand its own log name, so Grafana can tell "degraded but serving" from "both down". A fault now reads Postgres once and skips the cache refill, since a second command against a faulted Redis only stalls again.Depends on nothing in #6826, which stops the connection leak. That one is the urgent half; this is the hardening that keeps a future Redis fault from becoming a site outage.
Testing Before and After
Three log names now instead of one, so a reviewer can see which subsystem failed:
get_all_breaches_from_dbget_breaches_from_redis_failedget_all_breaches_from_dbget_all_breaches_from_db_failedget_all_breaches_from_dbset_breaches_in_redis_failedCaught unplanned: a production build ran while Redis happened to be down and completed anyway, serving all 1,005 breaches from Postgres on every prerender. On
maineach of those prerenders would instead have fired a live HIBP fetch and upsert.How to test
npx vitest run src/utils/hibp.test.ts \ src/app/functions/server/getBreaches.test.tsEach regression case fails on
main, which reports:hibp.test.ts:[]instead of the Postgres rows, and blames Redis for a Postgres timeoutgetBreaches.test.ts: an empty catalog, because the Redis fault reached HIBPChecklist (Definition of Done)
docs/architecture/flows/breach-read-path.mdnow distinguishes a cache miss from a cache fault.getBreaches.tshad none before this PR.Follow Up Action
getAllBreachesFromDbstill returns[]when Postgres fails, andgetBreachesstill answers that with a per-request HIBP fetch plus upsert. Same amplifier, different trigger, and the likelier remaining one now that the Redis path is fixed. The comment above that branch says so rather than hiding it.