Fix repeated SQLite FTS startup rebuilds#638
Conversation
🦋 Changeset detectedLatest commit: 2993eb4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
All contributors have signed the CLA ✍️ ✅ |
Scope checkThis PR changes 16,382 lines across 100 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
f61db90 to
490cb56
Compare
|
I have read the CLA Document and I hereby sign the CLA |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Pull request overview
Fixes incorrect startup FTS “out of sync” detection on SQLite when collections contain soft-deleted rows by changing how indexed-row counts are computed.
Changes:
- Update FTS verification and index stats to count indexed rows via the FTS
*_docsizeshadow table (instead ofCOUNT(*)on the external-content virtual table). - Add an integration test covering the soft-delete scenario (and a missing-table repair scenario).
- Add a changeset describing the patch release.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/search/fts-manager.ts | Switches indexed-row counting to use the FTS docsize shadow table for verification/stats. |
| packages/core/tests/integration/search/fts-repair.test.ts | Adds integration coverage for FTS repair behavior, including soft-delete regression. |
| .changeset/ten-flies-admire.md | Adds release note for the SQLite FTS rebuild fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
490cb56 to
2993eb4
Compare
What does this PR do?
Fixes repeated SQLite FTS startup rebuilds when collections have soft-deleted content.
The runtime startup verifier compared non-deleted content rows to
COUNT(*)on the external-content FTS virtual table. On SQLite, that count reflects the backing content table, including soft-deleted rows, so the verifier could decide the index was out of sync on every cold start and rebuild it repeatedly.This patch switches both startup verification and index stats to count rows from the FTS
docsizeshadow table, which reflects the rows actually present in the full-text index. It also adds a regression test covering soft delete.Closes #
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runpnpm locale:extracthas been run (if applicable)AI-generated code disclosure
Screenshots / test output
pnpm --filter emdash typecheckpasses locally.packages/core/tests/integration/search/fts-repair.test.tsis currently blocked on this machine by a localbetter-sqlite3Node ABI mismatch.sqlite3: after a soft delete,COUNT(*)on the external-content FTS virtual table still reflected the backing table total, while the..._docsizeshadow table matched the actual indexed row count.