Repository navigation
Closed
Closed
[Bug]: Renaming a Fulltext2 INCLUDE column leaves stale metadata and stops incremental indexing#27964
Bug
Copy link
Labels
kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Milestone
Description
Description
Renaming a column that is listed in a Fulltext2 index INCLUDE clause leaves the persisted include-column metadata stale. Subsequent inserts remain in the base table but are not indexed by the Fulltext2 incremental-maintenance path.
Environment
- Branch:
main - Commit:
33af6ae3c0c23e4f277137460577ea64678f7ecf - Deployment: isolated local single-CN/single-TN instance
- Test date: 2026-09-01
Steps to reproduce
SET experimental_fulltext2_index = 1;
CREATE TABLE renamed (id BIGINT PRIMARY KEY, body TEXT, status INT, prio INT);
CREATE TABLE control_t (id BIGINT PRIMARY KEY, body TEXT, status INT, prio INT);
INSERT INTO renamed VALUES (1, 'alpha original', 10, 100), (2, 'beta only', 20, 200);\nINSERT INTO control_t SELECT * FROM renamed;\nCREATE FULLTEXT2 INDEX ft_ren ON renamed(body) INCLUDE(status, prio);\nCREATE FULLTEXT2 INDEX ft_ctl ON control_t(body) INCLUDE(status, prio);\n\nALTER TABLE renamed RENAME COLUMN status TO state;\nINSERT INTO renamed VALUES (3, 'alpha incremental', 30, 300);\nINSERT INTO control_t VALUES (3, 'alpha incremental', 30, 300);\n\n-- Wait for asynchronous index maintenance, then compare.\nSELECT id FROM renamed WHERE MATCH(body) AGAINST('alpha') ORDER BY id;\nSELECT id FROM control_t WHERE MATCH(body) AGAINST('alpha') ORDER BY id;\nSHOW CREATE TABLE renamed;\n```\n\n## Actual behavior\n\nAfter a 30-second observation window, the renamed table returns only `1`; the no-rename control returns `1, 3` within 2 seconds. The base table has all three rows. `SHOW CREATE TABLE renamed` still renders `INCLUDE (status, prio)`, although `status` no longer exists. Both Fulltext2 catalog rows also retain `included_columns` containing `status`.\n\n## Expected behavior\n\nThe rename must rewrite Fulltext2 INCLUDE metadata to `state`, `SHOW CREATE TABLE` must render the valid new column name, and the inserted matching document must be returned just as it is by the no-rename control.\n\n## Stability and controls\n\n- Controlled reproducer: 3/3 on latest official main.\n- Control: the identical Fulltext2 INCLUDE index without column rename indexes the new document and returns `1, 3`.\n- Timing control: the renamed table still omits document `3` after 30 seconds; the control becomes correct at 2 seconds.\n- Metadata check: 3/3, both `SHOW CREATE TABLE` and `mo_catalog.mo_indexes.algo_params` keep the old include name.\n- Cleanup: all temporary databases were dropped after each run.\n\n## Code analysis\n\n`pkg/sql/plan/build_alter_rename_column.go` rewrites `IndexDef.Parts` and `mo_indexes.column_name` for an indexed key. INCLUDE-column metadata is delegated to optional plugin alter hooks. The Fulltext2 plan plugin does not implement `AlterColumnHooks`, so its `included_columns` payload is not rewritten. This matches the stale catalog payload and broken incremental-maintenance behavior above.\n\n## Regression coverage\n\nAdd a distributed Fulltext2 regression under `test/distributed/cases/fulltext2/`: create an index with INCLUDE columns, rename one include column, assert `SHOW CREATE TABLE` and catalog payload use the new name, then assert post-rename insert/update is searchable. Cover a no-rename control and a duplicate-target rename rejection.\n\n## Related\n\n- #27950 is distinct: it concerns DATA BRANCH materialization, not ALTER COLUMN metadata rewriting.Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Activity
cpegeric commentedon Sep 2, 2026
The right fix is to disallow user to rename the included columns too.
fix(fulltext2): implement ALTER-column plan hooks for INCLUDE columns (…
cpegeric commentedon Sep 2, 2026
please verify and close
Ariznawlll commentedon Sep 3, 2026
测试版本
main17c161a31b47a22e71ca222839143f66717ac365原问题验证
原问题是在 Fulltext2 索引的
INCLUDE(status, prio)中将status重命名后,目录元数据仍保留旧列名,后续增量写入虽然进入基表但无法被 MATCH 搜索到。当前 main 上按原复现步骤执行,重命名后插入alpha incremental,等待异步索引维护 10 秒后,重命名表和未重命名 control 表的 MATCH 结果均为1, 3。Happy Path 覆盖
FULLTEXT2(body) INCLUDE(status, prio)索引。ALTER TABLE renamed RENAME COLUMN status TO state成功。SHOW CREATE TABLE显示INCLUDE (state, prio)。mo_catalog.mo_indexes.algo_params两条记录均为{"included_columns":"[\"state\",\"prio\"]","parser":"ngram"}。1, 3。Unhappy Path 覆盖
ALTER TABLE renamed RENAME COLUMN prio TO state,按预期返回ERROR 1060: Duplicate column name 'state'。id, body, state, prio,行数仍为3,连接继续可用(select 1返回1),确认重复目标重命名是原子的。白盒验证
本次验证对应修复提交
e0a8738651(Fulltext2 INCLUDE 列 ALTER plan hooks,合入为 #28009),其作用是把列重命名同步改写到 Fulltext2 INCLUDE 元数据;上述SHOW CREATE TABLE和mo_catalog.mo_indexes.algo_params已直接验证新列名持久化。回归测试
已加入 MOTR:
motr#141,测试文件suites/14_issue_regression/t/issue_27964_fulltext2_include_rename.test。23/23statements passed。3/3通过(每轮23/23)。测试证据
MOTR 三轮总计:
6个 case 执行成功,129/129statements 通过。每轮均包含异步索引等待、MATCH 对比、目录元数据校验、重复目标重命名错误恢复和清理。最新 main 已修复 #27964 描述的问题,Happy/Unhappy 场景均通过;黑盒回归已加入 MOTR,不需要 big-data、stability 或 chaos 专项。
测试结论
测试通过。
fix(fulltext2): implement ALTER-column plan hooks for INCLUDE columns (…
fix(fulltext2): implement ALTER-column plan hooks for INCLUDE columns (…
fix(fulltext2): implement ALTER-column plan hooks for INCLUDE columns (…