Repository navigation
fix(fulltext2): evict idle search cache after CDC flush so incremental DML is visible (#30401) - #30606
Conversation
…emental DML is visible (matrixorigin#30401) A FULLTEXT2 index built the initial (pre-create) rows correctly, but an INSERT/UPDATE/DELETE after CREATE stayed invisible to MATCH for ~10 minutes. The deltas were in fact materialized into cdc_tail frames by the ISCP consumer -- the warm in-memory search cache simply never refreshed to include them, so MATCH kept serving the create-time snapshot until the ~10-minute async stale sweep (VectorIndexCacheTTL/2 x 4) finally evicted it. matrixorigin#29227 removed the post-flush idle-evict from RunFulltext2 (and the EvictIdleCache helper), leaving the stale sweep as the only refresh path. Restore it: after a CDC tail flush that wrote frames, drop the cache entry IF idle so the next query reloads the appended tail. RemoveIdle evicts only when no search is in flight, so it never thrashes concurrent readers (a busy entry stays warm and refreshes later via the sweep). The reloaded object is a fresh read-only generation, so the read-only-cache contract is unchanged. The evict is local to the CN that hosts the CDC consumer, giving read-your-writes on the single-CN standalone case; a different querying CN still converges via the sweep. Verified end-to-end (default freshness, no ctl override): a post-create INSERT is searchable in ~3s and an UPDATE's new/removed terms in ~10s, versus ~10 minutes before. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
mo-bot review · Commit: "interrupted" |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: ac830dd97915b5cff23bbfce485c59ff9d1e49e5
Assessment: approve
Reviewed the complete four-file delta and affected callers. The scoped fix reasonably reuses existing cache ownership to evict idle live entries after successful, nonempty CDC commits. Commit ordering, active-reader protection, snapshot isolation and cleanup are preserved. No actionable defects remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Isolation preflight passed. Initial testing stopped on missing native prerequisites; rebuilding through the repository owner in an exact-candidate diagnostic snapshot resolved setup, and native provenance verified.
-
TestEvictIdleCache, TestRunFulltext2RefreshesIdleCacheAfterNonEmptyCDCFlush and TestRemoveIdleEvictsIdleButKeepsBusyAndSnapshots each passed measurement and 100 separate exact-test repetitions under -race.
-
Full pkg/fulltext2, pkg/iscp and pkg/vectorindex/cache suites passed once under -race, with no failed or skipped tests.
-
Reconciled commands, source fingerprints, exit receipts and retained logs; confirmed source remained unchanged. Detailed evidence: /home/xupeng/.local/state/mo-bot/jobs/457020f446865fb9a06adde1/attempt-1/review-audit.json.
-
Reviewed frozen exact-head CI successes and traced delete-only frames, empty flushes, transaction failures, cancellation and plugin wiring.
Limitations:
-
Invalidation is single-shot and local: busy entries and other CNs retain eventual refresh behavior. This does not provide strict read-your-writes consistency.
-
Successful eviction requires a full index reload on the next query. That freshness tradeoff can increase fulltext workload I/O and latency; no quantitative performance comparison was performed.
-
The consumer test mocks SQL execution and the search backend. Author-reported default-freshness SQL timings lack retained logs; the standalone linked issue body and raw CI logs were not supplied.
Merge Queue Status
This pull request spent 7 hours 15 minutes 59 seconds in the queue, including 55 minutes 42 seconds running CI. Required conditions to merge
|
QA verification on
|
| Step | Query | Result |
|---|---|---|
| baseline | match(body) against('hello') |
1 |
after insert (3,'hello again') |
same | 1, 3 — new row visible without manual flush |
after update ftx set body='changed words' where id=2 |
against('goodbye') |
empty (old term no longer matches) |
against('changed') |
2 (new term matches) |
|
against('world') |
1 (unaffected row still matches) |
|
after delete where id=1 |
against('hello') |
3 |
So the stale-cache symptom this commit targets (incremental DML invisible until a manual flush) did not reproduce: insert/update/delete are all reflected on the next query.
One caveat for the record: during an earlier exploratory run I observed a single against('goodbye') → id=1 result after the same update. I could not reproduce it in 10 subsequent iterations (4 aggregate-shaped + 3 plain-select + 3 mixed), so I am not filing it as a defect; if it resurfaces under concurrent DML, the search-cache eviction path is the first place to look.
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [x] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #28005 ## What this PR does / why we need it: Document the idle-cache refresh implemented by #30606 and the effect of the MATCH transaction read point on reload. Issue #28005 still requires strict cache retention across CDC commits. Its QA result remains a failure against that requirement, and the product decision must account for the visibility requested in #30401. The matrix records evidence needed for either decision and keeps historical strict-retention results tied to their original build. QA required: yes The deployment matrix covers exact MATCH IDs across read points and CNs, durable tail and watermark outcomes for empty batches and rollback/retry, and resource release during ordinary eviction, MERGE, REBUILD, graceful shutdown, cancellation, and partial load failure. It distinguishes per-generation mappings and file holds from shared index-file cache entries retained under their own policy. The Linux failed-load mmap test and deployment QA remain pending for this revision. ### Validation - Documentation whitespace check and `mo-pipe preflight` passed locally for `cfa32b10a2ce66a055c3e3cbb80f790f08b967b8` against `275030e3c51a83962786f5a4317934a9ec2c3212` after synchronizing with `main`. The complete PR patch is byte-for-byte identical to the patch reviewed at `bfc477a0618f764f568bfba0ca4a778b88ea245b`. - BVT: N/A for the Markdown-only change. Component tests and deployment QA were not run for this revision. Approved-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #30401
What this PR does / why we need it:
A
FULLTEXT2index indexed its initial (pre-create) rows correctly, but anINSERT/UPDATE/DELETEissued afterCREATE FULLTEXT2 INDEXstayedinvisible to
MATCH ... AGAINSTfor ~10 minutes.Root cause
The deltas are not lost. The ISCP consumer materializes them into
cdc_tailframes correctly (confirmed: the frames are on disk, and a processrestart — fresh cache — shows every incremental row). The defect is that the
warm in-memory fulltext2 search cache never refreshes to include new
cdc_tailframes in a live session, soMATCHkeeps serving the create-timesnapshot until the ~10-minute async stale sweep (
VectorIndexCacheTTL/2 × 4)finally evicts the entry. DROP+recreate "fixes" it only because it builds a
fresh cache object.
#29227 removed the post-flush idle-evict from
RunFulltext2(and theEvictIdleCachehelper), leaving the stale sweep as the only refresh path.Fix
Restore the idle-evict: after a CDC tail flush that wrote frames, drop the
cache entry if idle so the next query reloads the appended tail.
RemoveIdleevicts only when no search is in flight, so it never thrashesconcurrent readers — a busy entry stays warm and refreshes later via the
sweep. This was fix(fulltext2): keep warm search cache across ordinary CDC flushes #29227's stated concern, and idle-only addresses it.
read-only-cache contract is unchanged.
read-your-writes on the single-CN standalone case (the reported setup); a
different querying CN still converges via the sweep (unchanged cross-CN
eventual behavior).
Validation
TestEvictIdleCache(idle→evict+destroy, absent→no-op) and
TestRunFulltext2RefreshesIdleCacheAfterNonEmptyCDCFlush(a committednon-empty CDC flush evicts the idle warm entry; the next reader reloads the
committed row; a mid-flush reader is never yanked). Full
pkg/fulltext2andpkg/iscppackages pass.(no ctl override): a post-create
INSERTis searchable in ~3s and anUPDATE's new/removed terms in ~10s, versus ~10 minutes before.No BVT timing assertion is added for the evict path: at default freshness the
idle-evict is single-shot per flush, so a polling
MATCHwould create busywindows that can make the single
RemoveIdlemiss (flaky). The existingfulltext2_asyncwarm_refreshcase already covers the sweep refresh pathrobustly (via a 1s freshness override) and still passes with this change.
🤖 Generated with Claude Code