Skip to content

fix(fulltext2): keep warm search cache across ordinary CDC flushes - #29227

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/fulltext2-cdc-cache-readonly
Sep 23, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/fulltext2-cdc-cache-readonly

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Related to #28005. This is the ordinary-CDC read-only cache-contract repair; the issue remains open for deployment QA.

What this PR does / why we need it:

Do not evict a warm FULLTEXT2 search object after an ordinary CDC tail flush. The flush makes the new tail durable, but the already-loaded search object stays read-only; subsequent visibility follows the existing generation, stale-sweep, and TTL lifecycle. This avoids making every CDC update trigger a synchronous cache replacement that can block concurrent searches. Remove the now-unused FULLTEXT2-specific eviction helper. COPY ALTER initialization, empty-generation non-retention, generic cache operations, and DDL cleanup are unchanged. No Base-file reuse prototype is included.

The consumer regression drives a non-empty encoded INSERT through RunFulltext2 and the real vector-cache wrapper. A concurrent warm read completes across the commit barrier. After commit, the same object remains loaded and still shows its pre-commit snapshot. Advancing only that entry across its ordinary TTL boundary and calling real housekeeping destroys the old object once; the replacement loads once, sees the committed row, and final cleanup destroys it once. A permanently retained generation fails this oracle.

The public SQL BVT holds a warm MATCH after the CDC tail becomes durable, then polls the same query without explicit invalidation. It observes the added row only after the normal asynchronous stale sweep/replacement. This validates eventual visibility, not immediate CDC visibility.

Validation

Exact source head: 3552afbefacda7d205b12740362b7f7018e3e4de; PR base at validation: a1d23f030cb57d5cfccc2799a2a48a33784fba59. The added commit changes only the consumer regression and fulltext2_async BVT SQL/expected result; production code is unchanged from the prior PR head.

  • pkg/iscp, pkg/fulltext2, and pkg/vectorindex/cache complete package tests: PASS. Complete race runs for those packages: PASS. The focused consumer test also passed race -count=20. Owning-package go vet, gofmt, and git diff --check: PASS. Tests used the repository mo-cgo-test wrapper and matching native dependencies.
  • Linux mo-129: built mo-service from the exact source snapshot with Go 1.26.4 and GCC 11 in a private directory; binary SHA256 4ff19931cb8468bd649ea5a91a5a49a576b8c6c6c76d33b741d9251bb8d43bf. The source files changed by this commit were SHA256-matched between the local worktree and the Linux build directory. The task's libmo.so resolved from its own directory.
  • test/distributed/cases/pessimistic_transaction/fulltext2/fulltext2_async.sql: PASS, 223/223 statements, 0 failed, 0 abnormal, exit 0, using matrixorigin/mo-tester 309a0ca650e0c55e90292767fd61e4976818d66d (./run.sh -n -g -p ...). The 900-second poll crossed the warm CDC transition: the service marked the index stale at 16:00:02 and the test advanced after the refreshed query returned IDs 1, 101 before its deadline. Full test duration: 918 seconds. The isolated service shut down cleanly with no task ports or processes left running.
  • The older mo-tester installed on that host did not support @wait_expect and failed existing asynchronous waits immediately. Its 77% diagnostic run is not counted as product or BVT evidence; the passing result above uses the current tester from a fresh private runtime.

The package test proves cache identity, Load/Destroy counts, commit/read ordering, and deterministic TTL replacement. The public SQL BVT proves ordinary stale-sweep eventual visibility. Neither implies immediate visibility or completes deployment QA for COPY ALTER, rollback, and concurrent production workloads. The separately skipped fulltext2_copy_alter BVT remains under #28985 and is not claimed as passing.

QA required: yes. The new head's GitHub CI and reviewer decision are separate gates; passing local/Linux validation does not imply either has cleared. No automatic issue closure or merge is intended.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 High deep review of exact head 3552afb: APPROVE. Ordinary CDC flushes intentionally retain the immutable warm cache snapshot; normal stale/TTL housekeeping eventually replaces it. The regression verifies retention through commit, TTL-driven refresh, updated results, and exactly-once cleanup; public BVT confirms eventual visibility. Temporary stale reads are part of this eventual-refresh contract. No concrete P1/P2 blockers found.

@mergify mergify Bot added the queued label Sep 23, 2026
@mergify

mergify Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-23 09:25 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-23 10:01 UTC · at fd3badae48aa73031852db92bbf77b579814a53e

This pull request spent 36 minutes 30 seconds in the queue, with no time running CI.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Reason

Pull request #29227 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

> The author needs to enable ["Allow edits from maintainers"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit ca71f51 into matrixorigin:main Sep 23, 2026
24 of 25 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 23, 2026
cpegeric added a commit to cpegeric/matrixone that referenced this pull request Sep 23, 2026
…; reconcile CDC narrative

Addresses the GPT-6 re-review P2s, reconciled with the main merge (matrixorigin#29227 removed the
CDC-flush RemoveIdle, so the periodic sweep is now the SOLE freshness mechanism).

- Startup-race (TestSetStaleCheckIntervalDuringServeIsNotLost): force both orderings
  deterministically (override-before-serve and override-after-serve) instead of only
  hoping a concurrent loop hits the window; every case (incl. the concurrent stress)
  reads effectiveTickerNs and Destroys BEFORE asserting, so a failed require never
  leaks a serve goroutine (unconditional cleanup).

- Automatic sweep dispatch (new TestPeriodicSweepTickerEvictsStaleEntry): drive a real
  serve() ticker at a ms cadence and assert it evicts a stale entry with NO manual
  checkStale/HouseKeeping call, and leaves a current entry resident -- proving ticker
  DISPATCH, not just that checkStale works when called. Replaces the RemoveIdle-based
  TestNonConsumerCNStaleEntryClearedOnlyBySweep, whose consumer-vs-non-consumer
  distinction is moot now that matrixorigin#29227 removed the CDC-flush RemoveIdle. (True separate-
  process CN placement remains out of the single-process test's reach.)

- fulltext2_copy_alter.sql: update the header narrative -- with matrixorigin#29227 there is no
  per-CN RemoveIdle shortcut, so the GetVectorIndexCacheInfo=0 poll is driven entirely
  by the periodic sweep on every CN.

Full pkg/vectorindex/cache passes under -race; the pessimistic fulltext2 BVT suite
(incl. copy_alter) passes 100%.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mergify Bot pushed a commit that referenced this pull request Oct 19, 2026
…l DML is visible (#30401) (#30606)

A `FULLTEXT2` index indexed its initial (pre-create) rows correctly, but an
`INSERT`/`UPDATE`/`DELETE` issued **after** `CREATE FULLTEXT2 INDEX` stayed
invisible to `MATCH ... AGAINST` for ~10 minutes.

### Root cause

The deltas are **not** lost. The ISCP consumer materializes them into
`cdc_tail` frames correctly (confirmed: the frames are on disk, and a process
restart — fresh cache — shows every incremental row). The defect is that the
**warm in-memory fulltext2 search cache never refreshes** to include new
`cdc_tail` frames in a live session, so `MATCH` keeps serving the create-time
snapshot 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 the
`EvictIdleCache` helper), 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.

- `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. This was #29227's stated concern, and idle-only addresses it.
- 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 (the reported setup); a
different querying CN still converges via the sweep (unchanged cross-CN
eventual behavior).

### Validation

- Unit tests (deterministic, cover the change): `TestEvictIdleCache`
(idle→evict+destroy, absent→no-op) and
`TestRunFulltext2RefreshesIdleCacheAfterNonEmptyCDCFlush` (a committed
non-empty CDC flush evicts the idle warm entry; the next reader reloads the
committed row; a mid-flush reader is never yanked). Full `pkg/fulltext2` and
`pkg/iscp` packages pass.
- End-to-end on a single-node standalone instance at **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.

No BVT timing assertion is added for the evict path: at default freshness the
idle-evict is single-shot per flush, so a polling `MATCH` would create busy
windows that can make the single `RemoveIdle` miss (flaky). The existing
`fulltext2_async` `warm_refresh` case already covers the sweep refresh path
robustly (via a 1s freshness override) and still passes with this change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Approved by: @XuPeng-SH
@VioletQwQ-0
VioletQwQ-0 deleted the codex/fulltext2-cdc-cache-readonly branch December 1, 2026 03:47

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants