Skip to content

[Bug]: FULLTEXT2 FORCE_SYNC rebuild leaves warm remote CN on the old generation #29080

Closed as not planned

Description

@Ariznawlll

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); -- 50

On 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 gamma control 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.py
  • evidence/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

Activity

  1. added this to the MO-202609 milestone on Sep 18, 2026
  2. added
    kind/bug
    on Sep 18, 2026
  3. added theissue type on Sep 18, 2026
  4. cpegeric commented on Sep 24, 2026

    @cpegeric
    Contributor

    By design, index in mutliple CN is evenutal consistency. So, WON'T FIX.

  5. cpegeric commented on Sep 24, 2026

    @cpegeric
    Contributor

    We will have mo_ctl command to control the cache soon. #29024

  6. Ariznawlll commented on Sep 27, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • MatrixOne main commit:5be6cd90b501da225be591ffffe6000bf01f515e
    • 部署:本地 2 CN / 1 TN / 1 LogService,分别直连 CN1 16001 与 CN2 16002

    原问题验证

    连续 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 覆盖

    • 两个 CN 在重建前均能读取同一初始 generation。
    • CN1 完成更新和 FORCE_SYNC 后正确读取新 generation。
    • CN2 的新连接也正确读取新 generation,稳定词 gamma 始终为 3。

    Unhappy Path 覆盖

    • 专门在 CN2 预热旧 generation 后再从 CN1 重建,覆盖原 issue 的跨 CN 缓存场景。
    • 三轮均检查删除词 alpha、新增词 beta 和不变词 gamma,避免只验证查询成功。

    白盒验证

    研发已在 issue 中明确:多 CN 索引缓存采用最终一致性,FORCE_SYNC 不构成所有 CN 的同步失效屏障;后续缓存控制能力见 #29024。本次立即收敛是当前实现观测,不升级为产品保证。

    回归测试

    未加入 MOTR:将“远端 CN 必须立即一致”录入回归会与研发确认的最终一致性契约冲突。该限制已补充到 Ariznawlll/mo-test-reports/mysql-compatibility-contract,commit 671b5d9。

    测试证据

    • 3/3 轮:CN1 3,0,3 -> 0,3,3
    • 3/3 轮:CN2 3,0,3 -> 0,3,3
    • 无 panic、无连接中断、稳定词计数无变化

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions