Repository navigation
Serve bounded-stale public reads during database outages - #167
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 025b4d9113
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if degraded and cache_state == "HIT": | ||
| # A cached body, inside the budget the same response publishes, | ||
| # served with the outage stated rather than implied. The | ||
| # shared-cache headers are deliberately left as they were: the | ||
| # CDN TTL is the route's own, which the registry derives at a | ||
| # third of the budget or less, so a downstream cache cannot | ||
| # carry this body past the bound stated on it. |
There was a problem hiding this comment.
Remove stale-while-revalidate from degraded responses
When a CDN honors the unchanged shared-cache headers during an outage, several default routes can be served beyond their published budget: the ordinary policy is max-age=5, stale-while-revalidate=30, while routes such as /public/v1/blocks advertise a 15-second budget. After revalidation begins returning 503, the CDN may therefore continue serving the degraded body until it is 35 seconds old, even though this branch claims downstream caching cannot carry it past the bound. Strip or cap stale-while-revalidate for degraded responses so the advertised staleness contract is enforceable.
Useful? React with 👍 / 👎.
| An unclassified path is not database-backed here because dispatch() 404s it | ||
| before it can read anything. | ||
| """ | ||
| endpoint = endpoint_registry.endpoint_for_request_path(path) |
There was a problem hiding this comment.
Treat artifact lookups as database-backed
On a cold or expired /public/v1/artifacts/{sha256} request during a database outage, this exemption still calls public_api.dispatch(), whose artifact handler invokes PsqlShareLedger.dashboard_public_artifact_document() and immediately runs a database query before it can resolve an externalized body. Consequently the supposedly outage-exempt route retries the unavailable database and becomes a generic 500; the new test misses this because its fake artifact ledger remains callable when the simulated database is taken down.
Useful? React with 👍 / 👎.
Closes #164.
Problem
In
PRISM_PUBLIC_REPLICA_MODE=off, the readiness probe could correctly report PostgreSQL unavailable while/public/v1continued calling the database or silently serving a warm cache entry without stating the outage.Design
Warning: 110 qbit-prism "database unavailable; serving cached response",X-Prism-Database-State: unavailable,Age, and the existing staleness-budget header.Cache-Control: no-store, without calling the database or refreshing the cache.PRISM_PUBLIC_REPLICA_MODE=requireon its existing stricter replica-freshness gate.Verification
python3 -m unittest tests.test_prism_public_read_service— 95 tests passed.docker,lab,tests,examples, andscripts.E4,E7,E9,Fpassed on both changed files.Residual risk
The live primary/standby replica gate was not run because it requires that topology. Its require-mode refusal remains ahead of and unchanged by this availability path, and focused coverage pins that a warm cache does not soften it.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.