fix(sdk): skip discarded catalog read on background tool-sync failure - #23
Open
polylane[bot] wants to merge 1 commit into
Open
polylane[bot] wants to merge 1 commit into
polylane[bot] wants to merge 1 commit into
Conversation
Co-authored-by: polylane[bot] <277585245+polylane[bot]@users.noreply.github.com>
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.
Fixes: D1 multi-MB read burst from discarded background tool-sync catalog reads
When an executor tool sync cannot list an MCP connection's tools, it re-reads that connection's whole persisted catalog from the database, and it does so even on background refreshes whose returned catalog is thrown away. On a catalog with large tool schemas those reads reach several megabytes: D1 response bytes on the Airbooks account hit 3.8 MB against a ~70 KB baseline in one bucket, with the matching rows-read metric at 19,517 rows, and the same shape recurred every few hours through the week. After this merge the background refresh stamps the sync time and leaves the catalog in place without copying it, while an explicit tool listing still returns the preserved catalog.
What caused this
Affected: Cloudflare account
fdd120ce6acd80e0c9812d5fbc910db0· D1 response bytes at 1.7Mbytes (baseline 268.1kbytes, 1.7σ above)Query that fired:
Cloudflare · d1AnalyticsAdaptiveGroups.sum.queryBatchResponseBytesWhy this fix
D1 response bytes (
queryBatchResponseBytes) on the Airbooks account's executor database rose from a 53,230–134,865 B per-bucket baseline to 3,809,396 B at 03:50Z on 2026-09-17, with the corroborating rows-read metric at 19,517 rows in the same bucket. The same three buckets (03:45–03:55Z) drive both checks, so this is one event; errors, refusals and resets stayed flat. The event recurs: hourly peaks of 2.7–15.1 MB with writeQueries ~70–150 (vs ~1 at baseline) across Sep 10–17.The burst coincides, to the second, with
executor tool sync preserved catalogwarnings at 03:51:02Z for thecloudflare/cloudflareOrgandchroma_mcp/mattOmegaMarketsComconnections, both failing MCP connect with HTTP 401. That branch runs whenresolveToolsreturns a non-authoritative listing: it keeps the persisted catalog and then materializes every tool row for the connection —input_schema/output_schemaincluded — to return them. An explicit tool listing genuinely needs those rows, but the stale-catalog fan-out runs these asbackgroundrebuilds and discards the returned catalog, so the whole-catalog read is pure D1 work on that path.The change skips the read when the in-flight sync is in
backgroundmode: the fan-out discards the result, and the catalog rows stay persisted, so nothing downstream changes. An explicit listing that joins the same in-flight sync flips its mode to explicit before the branch runs, so explicit callers still get the preserved rows and behavior is unchanged for them. The sync-time stamp and theexecutor tool sync preserved catalogwarning are untouched, so operators keep the signal that a connection's upstream is broken.Causal chain
1 file changed (+7/-0)
packages/core/sdk/src/executor.ts: modified, +7/-0Generated by Polylane. You can ask follow-ups by mentioning @polylane in a comment.