Repository navigation
fix(server): flushService evicts every cache entry resolved to the flushed database - #1962
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟠 1 high 💬 Inline comments (1)
The PR closes a stale-cache gap in the GraphQL server's flush endpoint: previously only hostnames still present in
Reviewed commit: 8be2509 |
There was a problem hiding this comment.
Adds a databaseId-based sweep of svcCache/graphileCache entries to the flush middleware so hostnames with deleted routing rows are evicted.
Key findings
- 🟠 In-flight handler creation repopulates
graphileCacheafter flush — flush.ts:98
Summary
flushService(opts, databaseId)droppedsvcCache/graphileCacheentries only for the hostnames the database currently lists (function_resolution.api_hostnames). An entry keyed by a hostname the database no longer lists therefore outlived its row and kept resolving.Now the flush also walks
svcCacheand evicts every entry whose resolveddatabaseIdis the flushed one (same key removed fromgraphileCache), then does the hostname lookup as before. Entries of other databases are untouched.Second gap, same mechanism: a handler build already in flight when the flush ran finished afterwards and re-inserted itself into
graphileCacheunder the flushed key. Every eviction now goes throughevictServiceKey(key)(middleware/cache-generation.ts), which advances a per-key generation; the build ingraphile.tsrecords the generation it started under and, at admission time, releases the instance and fails instead of caching if the generation moved. Coalesced waiters fall through to the existing retry path.Tests added:
flush.test.ts— a cached host that the routing lookup no longer returns is gone afterserver.flush(databaseId); another database's host stays.graphile-single-flight.test.ts— a build whose key is evicted mid-flight is not admitted (cacheGraphileInstancenot called,pgl.release()called once).Link to Devin session: https://app.devin.ai/sessions/19eee6ccb1fd4fbba8b54678699b3235
Open in Devin Desktop: https://app.devin.ai/desktop/session/19eee6ccb1fd4fbba8b54678699b3235?variant=devin
Requested by: @pyramation