chore(fts): remove failed FTS5 corruption recovery migrations 0002-0004#146
Merged
liplus-lin-lay merged 1 commit intoApr 29, 2026
Merged
Conversation
…04 (#135) production は本日 D1 time-travel restore (2026-04-23T12:00:00Z) で 0002 適用前の状態に復元済み。本 commit は source 側の掃除で、既に corruption を引き起こしたまま放置されていた失敗 migration を物理削除する。 0002 の `INSERT INTO search_docs_code_fts(search_docs_code_fts) VALUES('rebuild');` が 0001 で導入した AFTER INSERT trigger の `WHERE tokenizer_kind` 分岐を無視し、全 search_docs を code_fts (trigram tokenizer) にも強制 index した。8000 字の自然言語 nat content × 739 row ≈ 600 万 trigram が code_fts に流入し、FTS5 内部 segment が corruption。0003 (DROP+CREATE search_docs_code_fts + 再 'rebuild') と 0004 (trigger 再生成) は同じ 'rebuild' pattern を踏襲した復旧試行で、いずれも production で失敗した。storage 層の corruption が論理的な DROP+CREATE では除去できず、time-travel restore でしか抜けられなかった。 production の `d1_migrations` テーブルには 0002/0003/0004 の dummy 行を "applied" 状態で挿入済み。wrangler 側で再 apply は抑止される。 未来の fresh DB deploy は 0001 のみで初期化されるため、同じ罠を踏まない。 Closes #135
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
github-rag-mcp | bc1ca61 | Apr 29 2026, 10:45 AM |
liplus-lin-lay
commented
Apr 29, 2026
Member
Author
liplus-lin-lay
left a comment
There was a problem hiding this comment.
Self-review (auto mode)
削除対象の正当性
0002_fts5_rebuild.sql= 本 corruption の直接原因。INSERT VALUES('rebuild')が 0001 の trigger 振り分け (WHERE tokenizer_kind) を無視し全 search_docs を code_fts に強制 index、trigram explosion の入口。残す価値なし0003_fts5_code_recreate.sql= DROP+CREATE 後に再度'rebuild'を発行、同じ pattern を踏襲。production で失敗。残す価値なし0004_fts5_triggers_regen.sql= trigger 再生成のみだが、これも復旧フローの一部として失敗。0001 の trigger で十分。残す価値なし
3 本いずれも failed recovery 試行で、source tree に残すと未来の fresh deploy で罠を踏ませるだけ。delete 一択。
production 影響なし
- D1 は time-travel で 0002 適用前に restore 済み (今朝の作業)
d1_migrationsテーブルに 0002/0003/0004 の dummy "applied" 行を挿入済み、wrangler の再 apply 経路は抑止- 本 PR は source の git rm のみ、production state に副作用なし
未来 deploy 安全性
- fresh DB は
0001_fts5_init.sqlのみで初期化、trigger は WHERE 分岐で正しく振り分け 'rebuild'命令は今後 source に存在しないため、trigram tokenizer に nat content を流す経路は塞がれる
Deletion Impact (rules/task/deletion-impact.md)
- target = git-tracked source (recovery cost = instant revert)
- production state への到達経路なし (d1_migrations dummy + time-travel 完了済み)
- true caution = medium、本件は category 内で安全
LGTM, proceed to merge.
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.
経緯
本日、production D1 で再発していた
D1_ERROR: SQLITE_CORRUPT_VTAB(search_docs_code_fts) の root cause が特定され、D1 time-travel restore (2026-04-23T12:00:00Z) で復旧済み (issue #135)。corruption 経路:
0002_fts5_rebuild.sqlのINSERT INTO search_docs_code_fts(search_docs_code_fts) VALUES('rebuild');が 0001 で導入した AFTER INSERT trigger のWHERE tokenizer_kindによる振り分けを無視し、全 search_docs をsearch_docs_code_fts(trigram tokenizer) にも index 強制した本 PR の内容
source tree から失敗した recovery migration 3 本を物理削除する:
migrations/0002_fts5_rebuild.sqlmigrations/0003_fts5_code_recreate.sqlmigrations/0004_fts5_triggers_regen.sql残るのは
0001_fts5_init.sqlのみ (元の正しい schema)。production 影響
d1_migrationsテーブルには 0002/0003/0004 の dummy 行が "applied" 状態で挿入済み、wrangler 側で再 apply は抑止される未来の fresh deploy 安全性
新規 DB は 0001 のみで初期化されるため、
'rebuild'pattern による trigram explosion → corruption の罠を踏まない。Closes #135