perf(rest): cache hostname→env resolution (P1-4); document cluster pub/sub durability (P1-5)#1589
Merged
Merged
Conversation
…b/sub durability (P1-5) P1-4: resolveByHostname() ran on every unscoped request (a control-plane DB lookup in the hot path). RestServer.resolveHostnameCached() now caches hostname→environmentId for 30s across all 3 call sites, including negative results so unknown hosts don't hammer the registry; registry errors aren't cached so a transient blip self-heals. +3 tests. P1-5: verified the Redis pub/sub fire-and-forget is by design (at-most-once) and already implied in code. Recorded the durability contract in pubsub.ts: metadata.changed is a cache-invalidation hint only — the durable source of truth is the transactional sys_metadata (+ sys_metadata_history) write, so a missed event self-heals on reload and never loses data. No delivery-semantics change; risk accepted + documented. docs/launch-readiness.md P1-4/P1-5 updated (Verify ✅, Sign-off left for the team). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Closes launch-readiness P1-4 (real fix) and P1-5 (verified by-design; documented & accepted). Both hand-verified against
mainfirst.P1-4 — hostname→env resolution cache (real fix)
RestServer.resolveProtocol()calledenvRegistry.resolveByHostname()on every unscoped request — a control-plane lookup (typically a DB query) in the hot path, at 3 call sites, with no caching.Fix:
resolveHostnameCached()cacheshostname → environmentIdin-memory with a 30s TTL, used at all 3 sites. It caches negative results too (so unknown hosts don't hammer the registry) but not errors (a transient control-plane blip self-heals next request).P1-5 — cluster pub/sub durability (verified by-design, documented)
Redis pub/sub is at-most-once by design —
publish()already awaits the PUBLISH command, but there's no subscriber-delivery guarantee. Verified thatmetadata.changedis a cache-invalidation hint only: the durable source of truth is the transactionalsys_metadata(+sys_metadata_history) write. A node that misses the event serves a stale cached schema until its next reload and loses no data (self-heals against the DB).No delivery-semantics change. Recorded the durability contract in
pubsub.ts publish()and the doc; risk accepted for v1 (no exactly-once state may flow through this channel — durable state uses an outbox).Tests
+3 (
rest80 green): caches within TTL (1 lookup for 3 calls), refreshes after TTL, caches negative results.🤖 Generated with Claude Code