Repository navigation
Conversation
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? |
dcbfd5d to
28a79d1
Compare
|
Addressed the current-head invalidation race.
The pushed head is |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-reviewed exact head e88ade07b3d502a568d8705fb3597e846a336513 against the prior requested-change lifecycle race and the complete invalidation call graph. The new commit fixes the CDC consumer and compile hooks, but the same blocker remains in two production mutation paths:
[P1 observability correctness] Convert the MERGE and REBUILD TVF paths to single-owner invalidation too. These sites still explicitly publish a reason and then evict with the same reason:
pkg/sql/colexec/table_function/fulltext2_compact.go:127-128
pkg/sql/colexec/table_function/fulltext2_create.go:362-363
In both cases the sequence is still OnCacheInvalidated(reason) followed by Cache.RemoveWithReason(key, reason). If an entry exists, RemoveWithReason performs LoadAndDelete and then DestroyWithReason; a replacement load can install and peek the first reason while the removed old entry is waiting for its write lock, after which the delayed destroy callback writes the same physical invalidation again. Timestamp-aware consumption deliberately preserves that later write, leaving a phantom merge/rebuild reason for the following unrelated load.
The new regression only exercises the corrected manual OnCacheInvalidated + Remove sequence, so it cannot catch these unchanged real call sites. Please use reasonless Remove at both remaining explicit-notification sites and add production-path or exhaustive call-graph coverage proving no local CDC/MERGE/REBUILD path combines an explicit notification with reason-aware eviction. Reason-aware destroy must remain only for cache-owned TTL/generation-stale events.
The previous cancellation classification and failed-retry retention fixes remain correct. Full affected package suites (fulltext2, vector cache, compile plugin, ISCP, table functions) pass; focused observer/reason lifecycle tests pass under -race -count=20. Default-path overhead, bounded reason storage, phase/resource cleanup, and wait/lock ownership show no additional blocker.
XuPeng-SH
left a comment
There was a problem hiding this comment.
P1 — Publish TTL/stale invalidation before a replacement can load
The latest commit closes the remaining MERGE/REBUILD duplicate producers, but the cache-owned TTL and generation-stale path still loses the reason under the same real eviction/replacement interleaving.
HouseKeeping calls LoadAndDelete first, then DestroyWithReason. The latter waits for the old entry write lock before invoking OnCacheInvalidated. With an active reader:
- housekeeping removes the old entry and blocks on its lock;
- a replacement is installed and peeks no pending reason, so this actual TTL/stale reload is recorded as
process_start; - the old reader releases;
- delayed destruction publishes
ttl_expiredorgeneration_changed; - the next unrelated load consumes that phantom reason.
This leaves both adjacent events wrong, even though local CDC/MERGE/REBUILD now have a single producer. I reproduced the production HouseKeeping ordering on exact head 3d64abdde8637c9f5db7e600bce789336fcb4761 by holding the old entry lock: after the map entry disappeared, the replacement saw an empty reason; after destruction completed, the registry contained ttl_expired. The counterexample failed deterministically in the normal run and 20/20 under -race.
Please claim the exact old entry and publish its reason while it still occupies the key, then atomically remove it and perform reasonless destruction, with an exactly-once guard for competing eviction paths. Add a regression that blocks old-entry destruction and proves a replacement cannot start before the reason is visible and that no reason remains after a successful replacement load.
Validation after removing the temporary test: full ./pkg/fulltext2 ./pkg/vectorindex/cache passes; existing reason/cache regressions pass with -race -count=20; git diff --check passes.
|
Addressed the current-head P1 about TTL/stale invalidation being published after On exact head
Focused normal/race, |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 8b5cef5.
The prior TTL/stale publication race is directionally fixed, but one P1 exact-entry lifecycle race remains:
HouseKeeping snapshots only expired key strings during IndexMap.Range. In the later loop it calls IndexMap.Load(k) and claims whatever value currently occupies that key, without checking that it is the expired entry observed by Range or even rechecking Expired/stale. A normal concurrent sequence can therefore evict a fresh replacement:
- Range observes expired entry A and records key K.
- Before the eviction loop reaches K, another invalidation removes A and a query installs fresh, unexpired entry B at K.
- HouseKeeping loads B, publishes ttl_expired/generation_changed for B, CompareAndDelete removes B, and destroys it.
This causes an unnecessary second cold load, can force an in-progress query to retry, and leaves a phantom miss reason. It also contradicts the new exact-old-entry claim contract.
I reproduced the real HouseKeeping path deterministically: one expired entry blocks the first invalidation callback after Range has completed; while blocked, the other captured keys are normally removed and replaced with fresh unexpired entries; after release, HouseKeeping removes those fresh entries. The assertion failed in the normal run and in 20/20 race runs.
Please snapshot {key, expected *VectorIndexSearch}, verify the current map value is still that exact entry before claiming/publishing, and use CompareAndDelete against that expected value. If identity changed, skip it and let the replacement manage its own TTL. Add the replacement-between-Range-and-eviction regression.
Validation after removing the temporary counterexample: the two new TTL/replacement regressions pass under race for 100 repetitions; full pkg/fulltext2 and pkg/vectorindex/cache tests pass normally and under race; go list/build/vet, gofmt, and git diff --check pass.
|
Addressed XuPeng-SH's current-head exact-entry eviction finding in commit
Validation on the exact clean head:
Please re-review exact head |
There was a problem hiding this comment.
Deep re-review of exact head 380b32fbd888570ab4005d8df4cbc156088f6223 against the prior exact-entry housekeeping blocker and the complete PR diff.
The latest commit closes the blocker: HouseKeeping now snapshots {key, expected entry}, verifies the current map value is still that exact pointer, rechecks expiry/staleness, claims destruction exactly once, and uses CompareAndDelete against the expected value. A fresh replacement installed between Range and eviction is skipped, so it is neither destroyed nor assigned a phantom TTL/generation reason.
Lifecycle audit: Q1 ownership is single-winner through destroying.CompareAndSwap; Q2 invalidation is published while the old entry still occupies the key, map removal opens replacement, and destruction waits only for active readers; Q3 the temporary housekeeping snapshot is bounded by current cache cardinality and released after the sweep, while reason bookkeeping remains disabled by default and bounded when enabled. No blocking correctness, unhappy-path, leak, or default warm-path performance issue found.
Validation on the exact head: the replacement regression, publication-order regression, and FULLTEXT2 reason-consumption regression each passed under -race -count=100; full pkg/fulltext2, pkg/fulltext2/plugin/compile, and pkg/vectorindex/cache suites passed normally and under race; all five touched owning packages passed go list, go build, and go vet; gofmt and git diff --check passed.
What type of PR is this?
Which issue(s) this PR fixes:
issue #27445
What this PR does / why we need it:
Adds low-overhead FULLTEXT2 cold-load observability without changing query semantics, SQL/DDL, index format, CDC protocol, or public configuration.
Changes:
MO_FULLTEXT2_LOAD_TRACE=1switch or a package-private observer.Validation:
GOWORK=off go test -mod=readonly -count=1 ./pkg/vectorindex/cache— PASS.GOWORK=off go test -race -mod=readonly -count=1 ./pkg/vectorindex/cache— PASS.-race -count=100— PASS; the replacement test fails on old exact head8b5cef57f9c37ef00d24831f21f90625c59efbaabefore exact-entry snapshotting.GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -mod=readonly -count=1 ./pkg/fulltext2and-race -count=20— PASS.pkg/fulltext2normal/race suites — PASS.go list -mod=readonly,go build, andgo vet— PASS.test/distributed/cases/fulltext2/fulltext2_merge_forcesync.sqlcovers the production MERGE/REBUILD terminal path; mo-55 production SQL black-box evidence covers CDC/restart/TTL.git diff --check: PASS.PASS semantic=PASS) at exact head380b32fbd888570ab4005d8df4cbc156088f6223.QA required: yes — this changes cache invalidation diagnostics around CDC, restart, mmap and temporary-file lifecycle. Production terminal: FULLTEXT2 MATCH after restart, TTL, CDC, MERGE and REBUILD. Remaining deployed validation is recorded in #27445.
Current status: Ready for review; CI and reviewer re-review are pending on pushed exact head
380b32fbd888570ab4005d8df4cbc156088f6223.Non-goals: