Skip to content

[Performance]: keep FULLTEXT2 cache read-only across CDC updates #28005

Todo

Description

@VioletQwQ-0

Background

PR #27461 added FULLTEXT2 cold-load observability and cache invalidation lifecycle changes. PR #27462 was stacked on it and added reusable immutable bases plus incremental tail/delete loading across cache generations.

The required cache contract is simpler and stricter: a cached FULLTEXT2 index is read-only for its entire lifetime. Visibility delay after CDC is accepted. CDC must not evict, refresh, or incrementally update the cached search index.

Problem

When CDC evicts the warm entry, the next search creates and loads a replacement cache entry. The load is serialized by the cache entry write lock, so concurrent searches for that index can wait for the refresh. Triggering this after every incremental update can therefore block concurrent searches.

Reverting only #27462 is insufficient. #27461 is its prerequisite and also changes the invalidation lifecycle, while the older CDC consumer already calls Cache.Remove after a successful flush.

Required behavior

  • A cached FULLTEXT2 search index is immutable and read-only until ordinary stale/TTL eviction.
  • CDC persists tail frames but does not evict, mutate, or incrementally refresh the cached search index.
  • Visibility delay until the accepted stale/TTL boundary is allowed.
  • Concurrent warm searches do not wait for a CDC-triggered cache refresh.
  • Keep SQL, DDL, index format, ranking, and CDC wire protocol unchanged.
  • Preserve deterministic mmap/temp-file cleanup at ordinary eviction, shutdown, MERGE, REBUILD, errors, and cancellation.

Immediate action

The current-main revert must also retain safe failed-load cleanup and partial tail-load cleanup, because those are independent correctness requirements rather than incremental-cache reuse behavior.

Validation

  • FULLTEXT2 and vector-index cache package tests, including race coverage.
  • CDC plus concurrent-search regression proving warm cached readers are not refreshed or blocked by CDC.
  • TTL/stale eviction, MERGE, REBUILD, restart, cancellation, and cleanup coverage.
  • Production-path FULLTEXT2 BVT where the cache contract is SQL-reachable; otherwise document the precise BVT boundary and equivalent deterministic regression.

Related

QA decision

QA required: yes. This changes CDC visibility timing, cache invalidation, concurrent search behavior, and mmap/temp-file lifecycle. Deployment validation must cover CDC, stale/TTL expiry, MERGE, REBUILD, restart, and concurrent searches.

Activity

  1. self-assigned this
    on Sep 2, 2026
  2. VioletQwQ-0 commented on Sep 2, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    Draft PR #28017 implements the requested rollback of #27462 and #27461, removes CDC-triggered FULLTEXT2 cache eviction, and keeps the generic vector-cache lifecycle fixes from current main. Exact-head CI and the required QA validation are pending.

  3. VioletQwQ-0 commented on Sep 3, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    QA 交接(#28017 -> #28005)

    #28017 已合并,merge commit 为 1092ab739c120052fff0b8d1ff27854663cd098f;当前 main 为 362b1fba26a2dd7780f1af982c3760e3d5f7f721。请 @Ariznawlll 基于该 main 版本执行验证。当前 PR 页面显示 TKE 的 MO CHECKIN BVT TEST 仍为进行中,不能作为 QA PASS。

    本次需要覆盖:

    1. CDC 增量写入与并发 warm search,确认成功 flush 不会提前驱逐 warm FULLTEXT2 索引,且结果符合预期。
    2. stale/TTL replacement,确认到达既有替换边界后索引可正确替换。
    3. MERGE / REBUILD 后的查询与索引生命周期。
    4. CN/Proxy 重启后的加载、查询和缓存状态。
    5. 查询取消、中断和失败路径。
    6. 索引、文件、goroutine 等资源清理,无泄漏或异常残留。

    请在 QA 结果中写明精确 MatrixOne 版本/commit、CN 与 Proxy 拓扑、运行环境与架构,并对每个场景给出终态 PASS 或 FAIL 及必要日志/现象。只有全部要求场景得到终态 PASS 后才可关闭 issue;当前 issue 保持 OPEN,阶段为 phase/testing。

  4. Ariznawlll commented on Sep 18, 2026

    @Ariznawlll
    Collaborator

    在 latest main d9609d742b9000b54279f44e34295630b7238282 复核实现后,此 issue 不能按原描述关闭,需研发先明确产品契约。

    原 issue 的验收要求是:已缓存的 FULLTEXT2 索引在其生命周期内保持只读;CDC 写入不应驱逐、修改或刷新该缓存。

    当前实现与这一严格定义不一致:pkg/iscp/fulltext2_consumer.go 在 CDC tail flush 后仍调用 fulltext2.EvictIdleCache;后者经 pkg/fulltext2/search_cache.go 和 pkg/vectorindex/cache/cache.go 会移除没有 in-flight search 的 idle cache entry。因此当前代码实现的是“不会驱逐正在被读取的 cache、idle 后允许刷新”的较弱语义,而不是“生命周期内不驱逐”的原始语义。

    请确认并落实以下二选一的契约:

    1. 若承诺严格只读/不驱逐:移除 CDC 路径的 cache eviction,并补充 CDC 前后 cache identity 与查询可见性的回归。
    2. 若产品只承诺 reader-safe 的 idle refresh:更新 issue/文档,明确 busy reader 的保证、idle entry 的刷新时机和查询可见性边界,并据此补齐回归。

    MOTR #186 的多 CN CDC 脚本只能验证旧/新完整快照,不足以证明严格的“CDC 不驱逐 cache”契约。另请勿将本问题与 #29080 的 FORCE_SYNC/跨 CN 重建可见性混为一类;后者是独立场景。

  5. Ariznawlll commented on Nov 3, 2026

    @Ariznawlll
    Collaborator

    结论

    测试不通过。按本 issue 当前写明的“CDC 不驱逐缓存”契约,最新 main 的非空 CDC 提交后仍会驱逐无在途搜索的缓存;正在使用的缓存有保护。需要研发确认这一行为与要求立即看到新 tail 的相关需求之间的最终产品契约。

    关键证据

    • 版本:官方 main@1876b2f93e14c03ba538e3806e245e3c3203979a,macOS / Apple Silicon;执行 go test -race -p 1 ./pkg/iscp ./pkg/fulltext2 ./pkg/vectorindex/cache -run 'TestRunFulltext2RefreshesIdleCacheAfterNonEmptyCDCFlush|TestEvictIdleCache|TestRemoveIdleEvictsIdleButKeepsBusyAndSnapshots|TestFulltext2ConsumerContextCancelUnblocksRetrieverNext|TestFulltext2ConsumerCancelWhileWaitingForInput' -count=3,三包均通过。

    • Happy case:确定性组件测试在非空 CDC 提交受控阻塞期间执行 warm search,旧 backend 服务查询、候选 backend 不加载;cache 测试同时覆盖 busy entry、snapshot 和取消清理。

    • 与原契约的差异:上述 CDC 消费者测试 在提交后明确断言:空闲 warm backend 被销毁一次、原 cache entry 消失,下一次搜索加载新 generation 并观察 tail。实际 consumer 调用为 EvictIdleCache。这与 issue 中“CDC 不驱逐、只在 TTL/stale 边界替换”不同;不是说 busy reader 被强制驱逐。

    • 测试使用真实 CDC 编码和 consumer 流程,但 SQL executor、事务及 cache 后端为受控测试替身,不等同于完整部署的多 CN 并发搜索、TTL、MERGE / REBUILD、重启及 mmap 生命周期验收。

    • 双 CN SQL 补充:现有 issue_28005_fulltext2_cdc_cache_multi_cn 在两个直接 CN 上重复 3 轮通过;每轮 24 个并发查询在 15 秒内返回完整旧或新结果,CDC tail 持久化、MERGE 和本地 REBUILD 对照通过。该脚本允许完整的新 generation,不能证明 CDC 未驱逐缓存,也没有执行实际 CN/Proxy 重启或 TTL 等待。

    待解决点

    • 请研发明确是恢复本 issue 的严格不驱逐语义,还是保留 reader-safe 的 idle refresh 并同步修订契约;同时核对 #30401 对提交后可见性的需求,避免两个要求相互矛盾。契约确定后按其验收 CDC、TTL、取消、重启及资源清理。
  6. removed their assignment
    on Nov 3, 2026
  7. VioletQwQ-0 commented on Dec 1, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    QA 交接更新(#33589 → #28005)

    #33589 已合入 main(9081d1c140fdbc40dd6070d50986887266602191)。本次更新了 FULLTEXT2 缓存验收矩阵。PR 提交 cfa32b10a2ce66a055c3e3cbb80f790f08b967b8 的文档检查和 CI Required 已通过。此次合入仅涉及文档,现有「CDC 提交不驱逐缓存」要求下的 QA 结论仍为不通过。

    请研发先结合 #30401 的提交后可见性要求,明确采用严格不驱逐,还是保护正在搜索的缓存并允许空闲时刷新。契约明确且有对应可测构建后,请 @Ariznawlll 按矩阵复验,记录精确构建、部署拓扑和各场景终态。需核对多 CN 的 MATCH ID、空批次与回滚重试后的持久化结果,以及驱逐、MERGE、REBUILD、关停、取消和部分加载失败后的资源释放。本轮未执行 Linux mmap 加载失败测试或部署验收,issue 继续保持打开。

  8. cpegeric commented on Dec 2, 2026

    @cpegeric
    Contributor

    Decision (2026-12-02): strict cache retention across CDC commits is superseded by idle refresh with the index-file cache.

    • Current behavior (fix(fulltext2): evict idle search cache after CDC flush so incremental DML is visible (#30401) #30606): after a successful non-empty CDC flush, the consumer CN evicts the cached FULLTEXT2 entry only if it is idle (RemoveIdle). Busy readers finish on their immutable generation. Named-snapshot entries are untouched. Other CNs converge through the IsStale generation check. This provides the post-commit visibility requested in [Bug]: FULLTEXT2 index never indexes rows inserted/updated after index creation (incremental DML lost) #30401.
    • Reload cost: the base is stored as index files and mmap'd from the index-file cache on reload, so it is not rebuilt. The CDC tail is re-read and decoded into the Go heap on each reload: frames up to one chunk come from chunk rows by SQL, larger frames from index files. Tail reload cost is therefore proportional to the tail accumulated since the last MERGE.
    • Consequence: the performance concern behind keeping the warm entry resident across CDC commits is addressed by the index-file cache. The strict-retention acceptance criterion and the QA failure recorded against it no longer apply.

    The current behavior and the remaining lifecycle and resource checks are documented in docs/issue-plans/FULLTEXT2_28005_CACHE_TEST_MATRIX.md (#33589).

  9. Ariznawlll commented on Dec 2, 2026

    @Ariznawlll
    Collaborator

    结论

    未完成验收。 已按研发2026-12-02确认的新契约复测,不再把“非空CDC提交后驱逐空闲缓存”本身判为产品失败。本轮补齐真实双CN周期刷新和完整服务重启后的首次查询,均通过;Linux mmap加载失败资源释放、实际加载过程故障/取消及原始规模性能仍未完成,因此继续保持开放。

    关键证据

    采用的契约与版本

    • 以研发最新决策为准:非空CDC成功提交后允许RemoveIdle;忙读者使用不可变旧generation完成;命名snapshot不受此回收影响;其他CN由IsStale周期收敛。此前“严格不驱逐”的失败结论不再适用。
    • 官方main冻结于2026-12-02 23:14:51北京时间:6302cd4e33f0fb61eb99ea1ddc6e698ccdc6825d。从隔离源码构建,两个本地CN实际git_version()一致。部署为同一macOS arm64主机上的两CN、一TN、一LogService,专用目录/端口。
    • 运行跨午夜至12月3日;全部测试在本地,未使用128、129或TKE。没有把本地两进程说成真实双物理节点。

    真实SQL和周期刷新

    1. 既有issue_28005_fulltext2_cdc_cache_multi_cn.py正式三轮通过:两CN预热IDs1,2;插入3后先读取hidden storage确认cdc_tail chunk_id确实前进,再由16线程执行24次跨CN读,结果只允许完整旧/新集合。MERGE得到1,2,3,REBUILD得到1,2,3,4。
    2. 新增issue_28005_fulltext2_periodic_freshness.py,先读取GetVectorIndexCacheInfo,确认查询到2个CN且同一key至少有2个暖缓存条目。
    3. 等待新CDC tail真实持久化;调用产品现有SetVectorIndexFreshnessInterval('1s')测试开关,确认两个CN都成功应用且无failed结果。它改变周期ticker,不调用EvictVectorIndexCache,不手工删除缓存。
    4. 在两个直接CN连接轮询,允许完整旧集合过渡,最终必须都得到1,2,3。MERGE后仍完整;再插入4并REBUILD,两CN最终都得到1,2,3,4。任何部分集合均立即失败。
    5. 每轮finally恢复SetVectorIndexFreshnessInterval('0'),断言两个CN均恢复默认,无失败返回。
    6. 新矩阵直接三轮通过:232条实际SQL记录、0错误、3次明确的双CN默认间隔恢复;随后正式MOTR repeat=3再次3/3通过,0跳过。

    这里30秒只用于1秒测试ticker下的有界等待,不声明默认约10分钟周期已经做过实测,也不是生产SLA。使用该开关的用例默认opt-in,只接入隔离双CN job,避免随意改变共享环境的进程级配置。

    重启和白盒

    • 另建三轮独立持久化数据,每轮经历CDC写入、MERGE、REBUILD后,完整停止本任务MO服务并从同一数据目录启动。每轮两个CN的首次MATCH均返回IDs1,2,3,4:共6/6。均正常退出,未用强杀代替正常收尾;不宣称完成Proxy、网络故障或fencing测试。
    • 官方pkg/fulltext2和pkg/vectorindex/cache选中16个顶层case,-count=3共48次通过,失败/跳过0。涵盖idle回收、busy/snapshot保护、generation捕获及查询失败、portable mmap释放、读者取消和被替换加载的重试等。
    • 追加pkg/iscp三个顶层case各三轮:TestRunFulltext2RefreshesIdleCacheAfterNonEmptyCDCFlush、TestFulltext2ConsumerContextCancelUnblocksRetrieverNext、TestFulltext2ConsumerCancelWhileWaitingForInput,9/9。它们使用已有受控executor/backend夹具,明确不等同于真实SQL加载失败或Linux/proc映射释放检查。
    • 三包合计57个顶层执行通过。未执行-race,不冒称竞态检测通过。

    回归

    • 新用例和golden已追加同一个MOTR main #408,并接入隔离双CN的main branch-acceptance job;没有额外创建多个main PR。
    • 旧SQL driver仅修正注释,使其与最新“允许idle refresh”契约一致,没有放宽结果断言。证据说明在docs/qa/local-20261202.md。
    • 新用例加入后本地MOTR框架1080/1080通过,工作流YAML已解析检查。
    • 今晚所有测试按用户要求在本地,提交使用[skip ci],新head远端CI未运行、不能写成CI通过;未向MatrixOne主库提测试PR。

    待解决点

    • Linux-only TestFulltext2SearchLoadTailFailureReleasesOwnedMmap及真实/proc映射释放;本机macOS结果不能替代。
    • 真实加载中失败/取消、事务失败/回滚重试后的持久化与资源终态,以及Proxy等剩余生命周期边界。
    • 原始规模的暖读、tail reload开销与资源对照;没有用四行SQL夹具或单元测试充当大数据性能验收。
    • 新回归的托管CI、合入及每日执行记录尚待后续。

    最终结论:未完成验收。已通过:最新main本地双CN完整generation读取、加速周期刷新、MERGE/REBUILD、三轮重启后首次查询,以及57次portable原生控制;本轮已确认产品失败:无。未完成项:Linux mmap失败释放、其余真实故障/事务边界、原始规模性能和新回归CI。#28005保持开放,不转派。

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions