Skip to content

fix(db): chunk deleteResolvedReferences IN-list under the SQLite param limit (#1001)#1023

Merged
colbymchenry merged 1 commit into
mainfrom
fix/chunk-delete-resolved-refs-1001
Jun 27, 2026
Merged

fix(db): chunk deleteResolvedReferences IN-list under the SQLite param limit (#1001)#1023
colbymchenry merged 1 commit into
mainfrom
fix/chunk-delete-resolved-refs-1001

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Closes #1001.

What

QueryBuilder.deleteResolvedReferences() bound every id into a single unbounded IN (...), so a list longer than SQLITE_MAX_VARIABLE_NUMBER threw "too many SQL variables" — the one IN-list in queries.ts that #540 missed. Wrapped it in the same SQLITE_PARAM_CHUNK_SIZE loop every sibling query already uses.

Scope correction vs. the issue

The report is right that the method is unchunked, but two of its claims don't hold up — and the real exposure is narrower:

  • Not the resolution path. deleteResolvedReferences has zero callers in all of git history. Resolution uses deleteSpecificResolvedReferences, which binds per-row in a loop (no IN-list) and is immune — deliberately so (it's keyed on referenceName to avoid the gin re-resolve runaway). So the CLI/MCP indexing pipeline was never affected.
  • Trigger is 32766, not 999. Modern SQLite raised the default SQLITE_MAX_VARIABLE_NUMBER; probing the bundled node:sqlite confirms 32766 OK / 32767 throws. The issue's assumed 999 threshold doesn't reproduce.

The method is reachable through the exported QueryBuilder (library use), so this is a real latent bug worth hardening — chunked rather than deleted, since dropping a public method is a breaking change for a one-line fix.

Test

Regression test added next to the existing getNodesByIds chunking test, using 33,000 ids (past the real 32766 ceiling). Verified it throws too many SQL variables without the fix and passes with it. All 13 db-perf tests green.

🤖 Generated with Claude Code

…m limit (#1001)

deleteResolvedReferences bound every id into a single unbounded
`IN (...)`, so a list longer than SQLITE_MAX_VARIABLE_NUMBER (32766 on
the bundled node:sqlite) threw "too many SQL variables" — the one IN-list
in queries.ts that #540 missed. It's reachable only through the exported
QueryBuilder (library use): the internal resolution path uses
deleteSpecificResolvedReferences, which binds per-row and is immune, so
the CLI/MCP indexing pipeline was never affected. Wrap it in the same
SQLITE_PARAM_CHUNK_SIZE loop every sibling query uses, and add a
regression test (33k ids, past the real 32766 ceiling) that throws
without the fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deleteResolvedReferences is the one IN-list query not chunked -> "too many SQL variables" (follow-up to #540)

1 participant