Repository navigation
Description
Description
ALTER TABLE ... ALTER REINDEX ... FULLTEXT2 FORCE_SYNC only invalidates the FULLTEXT2 cache on the CN that executes the rebuild. A different CN with a warm cache continues returning the previous index generation after the synchronous ALTER has completed successfully.
This produces endpoint-dependent query results: the rebuilding CN returns the new documents while another CN returns deleted terms and misses newly indexed terms.
Environment
- Branch:
main - Commit:
01d60e1c4ded1b0f3fc1a4ecd75ce54e95e23b90 - Deployment: local 2 CN / 1 TN / 1 LogService; direct CN endpoints
Steps to reproduce
Run the setup and rebuild through CN1, and warm the old index through CN2 before the rebuild:
SET experimental_fulltext2_index=1;
CREATE DATABASE ft2_force_remote;
USE ft2_force_remote;
CREATE TABLE docs(id BIGINT PRIMARY KEY, body TEXT);
-- ids 1..50 contain alpha; ids 51..100 contain gamma.
INSERT INTO docs VALUES
(1, 'alpha old generation'),
-- ... same pattern through id 50 ...
(51, 'gamma stable generation');
-- ... same pattern through id 100 ...
CREATE FULLTEXT2 INDEX ft ON docs(body);
ALTER TABLE docs ALTER REINDEX ft FULLTEXT2 FORCE_SYNC;On both CNs, confirm the initial generation and warm CN2:
SELECT COUNT(*) FROM docs WHERE MATCH(body) AGAINST('alpha' IN BM25 MODE); -- 50
SELECT COUNT(*) FROM docs WHERE MATCH(body) AGAINST('beta' IN BM25 MODE); -- 0
SELECT COUNT(*) FROM docs WHERE MATCH(body) AGAINST('gamma' IN BM25 MODE); -- 50On CN1:
UPDATE docs SET body='beta new generation' WHERE id<=50;
ALTER TABLE docs ALTER REINDEX ft FULLTEXT2 FORCE_SYNC;Repeat the three MATCH counts through CN1 and CN2.
Actual behavior
After FORCE_SYNC returns:
CN1: alpha=0, beta=50, gamma=50
CN2: alpha=50, beta=0, gamma=50
CN2 continues serving the previous generation on new SQL connections. One reproduction polled it for 60 seconds with no change. Executing the same FORCE_SYNC rebuild locally through CN2 immediately changes CN2 to alpha=0, beta=50, gamma=50.
Expected behavior
When the explicit synchronous rebuild completes, subsequent current reads through every CN must use the committed generation. A warm cache on another CN must not keep returning deleted terms and false negatives for newly indexed terms.
Stability and controls
- Three independent databases reproduced the split result 3/3.
- Before the rebuild, both CNs returned the same
(50,0,50)counts. - The unchanged
gammacontrol remained 50 on both CNs. - CN1 returned the new
(0,50,50)generation immediately after each rebuild. - CN2 returned the old
(50,0,50)generation on three consecutive fresh connections in every round. - Rebuilding through CN2 recovered the new generation in all 3/3 rounds.
- A separate run kept CN2 warm and observed the old generation at 0, 10, 20, 30, 40, 50, and 60 seconds.
- The statements completed without panic, restart, or partial base-table changes.
Evidence
The standalone two-CN reproducer and output are retained as:
evidence/fulltext2_forcesync_remote_cache_stale.pyevidence/fulltext2_forcesync_remote_cache_stale.out
Code analysis
pkg/sql/colexec/table_function/fulltext2_create.go evicts the rebuilt index at the end of fulltext2_create, but the code explicitly notes that the eviction is local to the current CN:
// Local to this CN's cache.
veccache.Cache.Remove(u.tblcfg.IndexTable)pkg/vectorindex/cache/cache.go also documents Remove as process-local. A remote CN depends on the pull-based IsStale housekeeping path. That sweep runs every fourth VectorIndexCacheTTL/2 tick, approximately every 10 minutes with the default TTL, so a successful synchronous rebuild can leave a hot remote endpoint on the old generation for a long interval.
Regression coverage
Add a multi-CN motr case that warms generation A through CN2, performs FULLTEXT2 FORCE_SYNC generation B through CN1, and immediately verifies generation B through both endpoints. Cover fresh SQL and a prepared statement; the test must compare term membership, not only query completion.
Related
- [Performance]: keep FULLTEXT2 cache read-only across CDC updates #28005 permits bounded stale visibility for asynchronous CDC updates; this issue concerns an explicit
FORCE_SYNCrebuild that has already returned successfully. - [Bug]: COPY ALTER leaves an unaffected FULLTEXT2 index empty #28837 fixed a different empty-index lifecycle during COPY ALTER; here both generations are valid and each CN consistently serves a different one.
- Source exploration: [Bug]: v4.2.1 multi-CN IVF post search returns nondeterministic candidates due to unordered LIMIT merge #28943
Activity
cpegeric commentedon Sep 24, 2026
By design, index in mutliple CN is evenutal consistency. So, WON'T FIX.
cpegeric commentedon Sep 24, 2026
We will have mo_ctl command to control the cache soon. #29024
Ariznawlll commentedon Sep 27, 2026
测试版本
5be6cd90b501da225be591ffffe6000bf01f515e16001与 CN216002原问题验证
连续 3 轮在 CN2 预热旧 FULLTEXT2 generation,再由 CN1 更新数据并执行
ALTER ... REINDEX ... FULLTEXT2 FORCE_SYNC。每轮两端初始计数均为(alpha,beta,gamma)=(3,0,3);重建后 CN1、CN2 均立即变为(0,3,3),当前 main 未复现远端 CN 持续读取旧 generation。Happy Path 覆盖
FORCE_SYNC后正确读取新 generation。gamma始终为 3。Unhappy Path 覆盖
alpha、新增词beta和不变词gamma,避免只验证查询成功。白盒验证
研发已在 issue 中明确:多 CN 索引缓存采用最终一致性,
FORCE_SYNC不构成所有 CN 的同步失效屏障;后续缓存控制能力见 #29024。本次立即收敛是当前实现观测,不升级为产品保证。回归测试
未加入 MOTR:将“远端 CN 必须立即一致”录入回归会与研发确认的最终一致性契约冲突。该限制已补充到
Ariznawlll/mo-test-reports/mysql-compatibility-contract,commit671b5d9。测试证据
3,0,3 -> 0,3,33,0,3 -> 0,3,3测试结论
测试通过。