Repository navigation
Description
Background
FULLTEXT2 cache misses currently materialize the complete base index before serving a query. The reproduction was run on mo-55 with the exact binary from commit 94528dcb63d55921b936cda611ea61eb1862ea79, reusing the existing 2,303,643-row runtime. The result is directional only and is marked PERF_INCONCLUSIVE_HOST_BUSY.
The relevant load path is:
Fulltext2Search.Load
-> LoadAllBases
-> LoadFromStorage
-> streamChunksToFile
-> mmap/search
LoadFromStorage reads the tag=0 base chunks through internal SQL, writes a local anonymous file, and maps the materialized segment. A cache miss therefore performs multi-GiB local writes even when the query term has DF=1.
Reproduction evidence
Run artifacts:
/home/sunyuze/fulltext2-product-baseline-94528-20260820/results/coldload-repro-20260821/20260821-025000-coldload-repro-v4/
| Scenario | First query | Immediate repeat |
|---|---|---|
| Restart, high-DF term | 210 s, 2.61 GiB written | 13 ms stable warm control |
| Restart, DF=1 term | 234 s, 2.61 GiB written | 12 ms |
| 480 s TTL idle, unchanged generation | 213 s, 2.60 GiB written | 12 ms |
| CDC tail 3 -> 4 | 209 s, 2.60 GiB written | 0.5 s |
| MERGE FORCE_SYNC | 32.5 s, 2.89 GiB written | 12 ms |
| REBUILD FORCE_SYNC | 31.3 s, 2.81 GiB written | 12 ms |
The R3 generation stayed unchanged during the 480-second idle and reloaded on the next query. In R4 the tail advanced strictly from chunk 3 to chunk 4 before the query, and the next query reloaded the base. MERGE folded the tail and changed the metadata generation; REBUILD changed it again. All marker probes returned exactly one expected row and there were no query errors. A full exhaustive PK-set oracle was not part of this diagnostic run.
One R1 warm sample in v4 raced with a background CDC transition (tail 2 -> 3), so it is excluded from the warm comparison. The archived v3 run provides the stable 13 ms warm control.
Problem
The current invalidation granularity is the whole loaded search object. A tail flush or generation change removes the object, and the next query reloads all immutable base chunks instead of reusing the unchanged base and loading only the new tail/delete state. This creates multi-minute first-query latency and multi-GiB local temporary writes on a 2.3M-row index.
Proposed fix
Implement a conservative in-process immutable-base reuse path:
- Key the reusable base materialization by index identity and base generation, independently from the CDC tail generation.
- On tail-only invalidation, retain the immutable base segment and load only new tail/delete frames plus liveness state.
- Keep MERGE/REBUILD generation changes as explicit base replacement points; do not reuse a base whose storage generation changed.
- Add single-flight protection so concurrent cache misses do not materialize the same base more than once.
- Add bounded lifecycle accounting for retained mmap/temp files and deterministic cleanup on TTL expiry, MERGE, REBUILD, shutdown, and error paths.
- Add low-overhead counters or trace fields for base reuse, full materialization, tail-load bytes, local write bytes, generation, and load latency. Keep diagnostic tracing disabled by default.
The first implementation must preserve the current SQL and index formats. It should not require a new runtime-filter protocol or persistent cache format.
Non-goals
- No changes to SQL, DDL, FST, FULLTEXT2 index format, CDC wire protocol, or public APIs.
- Do not mix this work into P0 pure-MUST, P0.1 live-DF, P1 phrase positions, F1A membership, P2A term metadata, or safe candidate LIMIT.
- No claim about absolute QPS/P99 from the busy mo-55 host.
- No global unbounded cache or background cleanup goroutine without an explicit lifecycle design.
Acceptance criteria
- Restart cold-load behavior remains correct, but a warm repeat does not rematerialize the base.
- After a tail-only CDC flush, the next query reuses the unchanged base and does not write base-sized temporary data; only tail/delete work is proportional to the delta.
- TTL eviction, MERGE, REBUILD, shutdown, cancellation, and load errors release retained mmap/temp resources exactly once.
- INSERT/UPDATE/DELETE, tombstones, superseded PK copies, MERGE, REBUILD, and restart preserve PK membership and score semantics.
- Concurrent first queries perform at most one base materialization per
(index, base generation). - The cold-load reproduction is rerun with
R1throughR5; correctness has zero lost, duplicate, phantom, or stale markers, and no service crash. - Add production-entry BVT coverage for CDC invalidation/reload and the relevant restart or MERGE terminal behavior. Package tests alone are insufficient.
- Report cold/warm wall time, local read/write bytes, mmap bytes, RSS, generation, and tail bytes. Performance results remain host-validity qualified until repeated on a quiet host.
Related work
- Query/posting materialization: [Performance]: avoid full posting materialization for FULLTEXT2 pure-MUST queries #27245
- Loaded-PK membership probing: perf(fulltext2): avoid boxing loaded primary keys for runtime-filter probes #27247
- Query-local term metadata reuse: [Performance]: reuse FULLTEXT2 term metadata within a query #27250
- Safe candidate LIMIT: [Performance]: safely push candidate LIMIT for exact FULLTEXT2 pure-MUST filters #27251
QA decision
- QA required: yes
- Reason: this changes CDC invalidation, restart, cache lifecycle, mmap/temp-file ownership, and user-visible first-query latency.
- Production entrypoint: FULLTEXT2
MATCH ... AGAINSTafter restart, CDC tail flush, TTL expiry, MERGE, and REBUILD. - Automated terminal coverage: package/race tests, production SQL BVT, exact membership/score differential tests, and the cold-load reproduction harness.
- Remaining manual/deployed validation: repeated 2.3M-row runs on a quiet host and failure/cancellation/restart lifecycle checks.
Activity
VioletQwQ-0 commentedon Aug 21, 2026
2026-08-21 validation and PR update
The requested mo-55 black-box validation is complete on the exact
94528dcb63d55921b936cda611ea61eb1862ea79runtime. The candidate binary used for the fixed rerun is SHA2565be2d37bf34f2c49c9d6a3e408d3c603fd762c97baa5e2eaac214c883b6e1352.300K correctness
The fixed candidate passed INSERT, UPDATE, DELETE, rollback invisibility, repeated UPDATE latest-version selection, graceful restart, forced cancellation with the service alive, MERGE and REBUILD. The first candidate run exposed a real
tail_pool.gonil-map panic on an insert-only CDC delta; it is fixed by initializing/merging the delete state and covered byTestMergeTailDeletesInitializesInsertOnlyDelta. The initial cancellation attempt completed before the timeout; the corrected forced-timeout retry is the valid cancellation evidence.Artifact:
2.3M cold/warm evidence
Candidate artifacts:
Key structural comparison against the retained exact-base v4 run:
The candidate R1/R3/R4/R5 membership checks passed, and generation/tail transitions were recorded. All results are directional and marked
PERF_INCONCLUSIVE_HOST_BUSY; no absolute QPS/P99 claim is made. The diagnostic run did not include an exhaustive 2.3M PK-set oracle, so the issue remains open for QA and broader exactness validation.Draft PRs
Both are Draft and based on the current
upstream/main(dd040ad6913e9b86f592b574e5fffb610003f72a). #27462 is stacked conceptually on #27461; its second semantic commit isperf(fulltext2): reuse immutable bases across cache generations.Code validation
On mo-55 exact candidate build:
Existing
test/distributed/cases/fulltext2/fulltext2_merge_forcesync.sqlcovers the production MERGE/REBUILD terminal path. Restart/TTL byte-level assertions remain harness-only because distributed BVT cannot deterministically control process cache state and host I/O; this is called out as BVT N/A in the PR bodies. QA required remains yes for CDC, restart, cancellation, mmap and temp-file lifecycle.perf(fulltext2): add cold-load observability (#27461)
VioletQwQ-0 commentedon Aug 25, 2026
Post-merge evaluation for #27461:
mainat merge commit6dccc954a1a32c12a2114328c752f15cf97ef2bafrom head167a31287a5f66ef247520d1d96a96d17662d590.keep_open_other_gate. This PR is the observability portion of the stacked FULLTEXT2 work; the issue remains open because perf(fulltext2): reuse immutable bases across cache generations #27462 is still an open Ready PR for the immutable base/tail generation-reuse portion.No issue state, label, or assignment mutation was made.
perf(fulltext2): reuse immutable bases across cache generations (#27462)
VioletQwQ-0 commentedon Aug 25, 2026
QA handoff after merge
Issue #27445 remains open for production QA after the stacked implementation merged:
mainat merge commit6dccc954a1a32c12a2114328c752f15cf97ef2bafrom PR head167a31287a5f66ef247520d1d96a96d17662d590.mainat merge commitb8aa3f7f7351aacaaa37da27891d8f8d85e2e44dfrom PR head147b76e17c8e3edf50be18cd5fad4a65d3d65423.matrixorigin/matrixone:mainhead at handoff isa9d02fd3b4417f1e781e24f59bc580d6cdee0358.Automated evidence already recorded:
git diff --checkpassed on its reviewed content.QA scenarios and expected results:
Tester selection basis: the issue author is
VioletQwQ-0, notheni02; per the automation rule the tester isAriznawlll.VioletQwQ-0 commentedon Sep 3, 2026
Closing this issue as not planned.
The immutable-base reuse and incremental-refresh direction proposed here was intentionally reverted by #28017 (merged as
1092ab739c120052fff0b8d1ff27854663cd098f) after owner review. FULLTEXT2 cached indexes now follow a read-only lifetime contract: CDC persists updates without evicting or incrementally refreshing the warm search index, and the accepted visibility delay is handled by the ordinary stale/TTL lifecycle so CDC updates do not block concurrent searches on cache replacement.The replacement contract and its remaining QA follow-up are tracked in #28005. There is no remaining implementation work under the design proposed by this issue.
perf(fulltext2): add cold-load observability (matrixorigin#27461)
perf(fulltext2): reuse immutable bases across cache generations (matr…
perf(fulltext2): add cold-load observability (matrixorigin#27461)
perf(fulltext2): reuse immutable bases across cache generations (matr…
perf(fulltext2): add cold-load observability (matrixorigin#27461)
perf(fulltext2): reuse immutable bases across cache generations (matr…