Repository navigation
fix(fulltext2): fence cross-CN cache generations - #27806
VioletQwQ-0 wants to merge 24 commits into
Conversation
…ulltext2-cross-cn-fence # Conflicts: # pkg/defines/const.go # pkg/pb/query/query.pb.go
…ulltext2-cross-cn-fence
…ulltext2-cross-cn-fence
|
Follow-up on the current-head review: Pushed
The required exact-head direct-CN matrix remains pending. I have not treated proxy sessions, unit tests, or BVT as per-CN evidence, and the blocking review request remains in place until two independent prewarmed CNs cover INSERT/UPDATE/DELETE, rollback, lost RPC, post-commit sender interruption, restart, and join convergence. |
|
Exact merged-head direct-CN QA status for The run used two independent CN processes and direct SQL endpoints. Proxy sessions were not used as per-CN evidence.
Before the initial durable FULLTEXT2 tail appeared, CN2 exited with Consequently:
Historical pre-fix supporting evidence, not acceptance evidence: on the older exact-main baseline the first MATCH hit the DECIMAL128 aggregate/int64 decoder mismatch. Applying only the recorded one-line signed CAST let both independent CN processes run, and an UPDATE then produced the expected pre-fix split: consumer CN Exact-head local code gates are PASS: owning ordinary/race tests, both deterministic hook groups with Evidence identifiers:
The exact-head containers were removed; the named data volume is retained for reproducing the blocker. The PR remains Ready with direct-CN QA and formal review still pending. |
…ulltext2-cross-cn-fence # Conflicts: # pkg/fulltext2/storage.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Blocking review
This R3 distributed cache-coherence change cannot be approved yet.
-
Exact-head direct-CN acceptance remains missing. The issue requires stale-read exclusion after a durable CDC tail commit across independently serving CNs. The PR body records the required two-CN prewarm matrix as
BLOCKED_NOT_RUN; proxy BVT and unit/race tests do not identify or prewarm each serving CN. Please first rebase onto the latestmain, then attach final-head direct-CN evidence for INSERT/UPDATE/DELETE, rollback, one lost-RPC case, post-commit sender interruption, restart, and new-CN join. The current head is also behindmain, so older evidence is not reusable as final acceptance. -
Bound the failure-path operational amplification in the 30-second freshness sweep.
checkStale(..., fast=true)now runs every 30 seconds for every loaded FULLTEXT2 cache entry. AQueryGenerationfailure is treated as stale, logs oneWarnplus oneInfoper entry, evicts it, and active MATCH traffic reloads it for the next sweep. Therefore a persistent internal SQL/metadata outage with N active identities yields repeated O(N) logs and reload work every 30 seconds. Please aggregate/rate-limit this per-entry logging (and expose a counter/summary) before enabling the fast sweep globally.
|
@Mergifyio refresh |
✅ Pull request refreshed |
aptend
left a comment
There was a problem hiding this comment.
Deep review completed on exact head 3ccd4fb. I reviewed the full diff, design, issue, all reviews/comments/threads, and the lifecycle/concurrency paths. Three blockers remain:
-
Fence-registry overflow is not fail-closed for the omitted identity. In
pkg/fulltext2/coherence.go:172-176, capacity overflow returns without recording the new identity.InstallGenerationFencethen only bumpscoherenceEpochand claims currently visiblefulltext2:entries at:234-242; it neither installs the omitted lower bound nor retires that identity. A transaction whose snapshot predates the tail commit can start its first MATCH after this epoch bump:UseTransientLoadis false,requiredGenerationis absent, andLoadcaptures the already-bumped epoch, so the old generation passes both checks and is published globally before the sender retry. Later transactions can then acquire the stale object, violating the stated admission invariant. A minimal exact-head test with registry capacity 1, identity A left claiming, and identity B overflowing fails the required assertionrequiredGeneration(B) exists || UseTransientLoad(B): both are false. Keep the omitted identity transient/fail-closed until its exact fence is installed. -
The pull fallback is not bounded to 30 seconds and can exceed the issue SLA. In
pkg/vectorindex/cache/cache.go:684-717, the 16-slot semaphore is acquired before the goroutine is launched, while each five-second timeout is created only inside that goroutine at:697. With 1,024 loaded FULLTEXT2 identities and slow/hung generation reads, the last group does not even start until about 315 seconds;startStaleCheckis single-flight, so intervening 30-second ticks are discarded. Even two-second metadata reads place the last identities beyond the 120-second issue gate. Please make the whole population coverage/SLA explicit and bounded rather than only bounding each individual check. -
Exact-head multi-CN acceptance is still absent. The PR body records the required direct two-CN prewarm matrix as
BLOCKED_NOT_RUNafter the CN2 panic, including INSERT/UPDATE/DELETE, rollback, lost RPC, post-commit sender interruption, restart, and join. Unit/race/proxy coverage cannot establish per-CN stale-read exclusion for this distributed protocol. Please provide the final-head direct-CN evidence after resolving the environment blocker.
Local exact-head evidence: the overflow counterexample failed as described; the temporary test was removed. All owning-package tests passed for pkg/fulltext2/..., pkg/vectorindex/cache, pkg/cnservice, pkg/iscp, and pkg/queryservice/client; race tests passed for pkg/fulltext2, pkg/fulltext2/fencepublisher, and pkg/vectorindex/cache; go vet and git diff --check passed. GitHub exact-head CI is green.
aunjgr
left a comment
There was a problem hiding this comment.
Request changes: the mandatory distributed acceptance proof is still objectively missing. The design requires direct connections to at least two independently identified CN processes with both caches prewarmed, followed by mutation and rollback checks plus lost-RPC, sender interruption, restart, and join recovery. The PR body states that the current exact-head run hit an unrelated lockservice panic before the dual-prewarm gate and that all subsequent scenarios are BLOCKED_NOT_RUN. Standard green CI and proxy BVT do not establish per-CN cache attribution or this push/pull recovery contract. The design also has no recorded independent PASS. Resolve the acceptance blocker, run the design-required scenarios on the exact implementation head with every serving CN at the allocated protocol version, and record an independent design decision before requesting implementation approval.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review at exact head 963ec48594aa6d2cf679f5db094c40f5c9fba116. The latest commit fixes the previously reported omitted-fence overflow and serial 16-slot sweep scheduling, and it removes per-entry warning amplification. Two new blockers remain in the replacement design: timeout/error eviction is not a generation fence and can both republish an old transaction snapshot and trigger an O(N) reload storm; registry reclamation permanently disables caching for retired identities and cumulatively collapses cache effectiveness above the process-wide 1024-identity cap. In addition, the design-required exact-head direct-CN acceptance matrix is still explicitly BLOCKED_NOT_RUN in the PR body, so the distributed issue is not yet proven solved.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 44b0803. The earlier registry-cap, sweep-scheduling, and exact-head direct-CN evidence gaps are materially addressed, and the focused affected-package suite passes locally. Three remaining races still break the stated fence/availability contract: housekeeping can forget an acknowledged fence while a transient load is in flight; concurrent transient loads supersede each other through the global attempt counter; and fanout omits Draining CNs that can still serve existing/direct sessions.
| r.mu.Lock() | ||
| defer r.mu.Unlock() | ||
| for key, entry := range r.entries { | ||
| if !entry.claiming && !entry.recovering && !cachePresent(key) { |
There was a problem hiding this comment.
Blocking: pruneInactive only asks whether the generic IndexMap contains this key, but transient loads deliberately bypass that map. Repro: install/claim required H=(2,-1), mark the identity uncertain, start a transient MATCH whose caller transaction reads G=(1,-1), and pause its GenerationSQL read. If housekeeping runs now, it sees no IndexMap entry and deletes both the fence and uncertainty; after resuming, both required-generation checks in Fulltext2Search.Load see no bound, global admission is skipped for the transient object, and the stale G search succeeds after H was already ACKed. I reproduced this with a deterministic package test on this exact head. This contradicts the invariant at design lines 12-17 and the PR-body claim that in-flight identities are tracked. Keep the entry while transient loads are in flight, or give transient completion a durable validation/bound that cleanup cannot erase.
| return errLoadGenerationSuperseded | ||
| } | ||
| index := s.identity.Key() | ||
| generation := beginLoadGeneration(index) |
There was a problem hiding this comment.
Blocking: every transient Fulltext2Search.Load still enters the single per-identity loadGeneration attempt sequence. A later one-shot load increments state.attempt and makes every older overlapping one fail loadGenerationCurrent. Deterministic counterexample: pause transient request A after its generation read, let transient request B complete, then release A; repeat before each retry. Four ordinary overlapping B requests force A through all four attempts and it returns FULLTEXT2 cache coherence retry exhausted. I reproduced this on the exact head. Thus the timeout/error fallback that is supposed to preserve caller-snapshot availability can livelock/thrash a hot identity and return service unavailable under concurrent MATCH traffic. Transient one-shot loads need isolated or safely serialized reusable-pool bookkeeping rather than superseding unrelated transient requests.
| } | ||
| nodes := make([]metadata.CNService, 0, 4) | ||
| err = clusterservice.GetCNServiceWithoutWorkingStateWithContext(ctx, cluster, clusterservice.NewSelector(), func(cn metadata.CNService) bool { | ||
| if cn.WorkState != metadata.WorkState_Working && cn.WorkState != metadata.WorkState_Unknown { |
There was a problem hiding this comment.
Blocking: this excludes Draining CNs from every retry even though the work-state transition only starts asynchronous proxy tunnel migration; the CN frontend/query service and existing or direct sessions are still live. Counterexample: prewarm G on CN2, mark CN2 Draining, commit H on CN1, then issue MATCH on CN2 through an existing/direct connection before its pull sweep. Fanout never targets CN2 and can finish allAcked for the reduced inventory, so CN2 can serve stale G. This violates the every-live-v43-CN push invariant. Include Draining until the node is actually drained or its query address is withdrawn, or establish a fence that prevents it from serving before filtering it out.
cpegeric
left a comment
There was a problem hiding this comment.
We already have mechanism to clean up the stale cache every 5 mins. ( in pkg/vectorindex/cache). We can never clean the cache instantly in multiple CNs case. I don't think we need this mechanism.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-reviewed exact head 44b0803bdc64e1169fa60a603786bee3a5972abc against base c46d897e9645b80178568ef0783dd8e99e527222, including issue #27788, the full 42-file protocol/cache/CDC/queryservice change map, design invariants, all historical blockers, the latest convergence rewrite, direct-CN evidence, concurrency ownership, and Q1-Q3 unhappy paths.
The latest head materially closes the old fixed-cap retirement, serialized sweep, log-storm, and missing direct-CN evidence blockers. Three exact-head races remain:
-
[P1 stale read] Housekeeping can forget an acknowledged fence while a transient load is in flight.
pruneInactiveretains an entry only forclaiming,recovering, or a genericVectorIndexCache.IndexMapentry. Transient loads deliberately bypass that map. Therefore an identity can haverequired=H, uncertainty set, and a transient load from caller snapshotG < Hin progress, while the lifecycle sweep observes no map entry and deletes the entire fence entry. When that load resumes, the post-load required-generation check finds no bound, and transient mode skipsvalidateGlobalAdmission; the stale search can succeed after H was already ACKed. The separate load-generation active count is not consulted by registry pruning. Keep fence and uncertainty state while any transient load is active, or bind each transient completion to a durable requirement token that cleanup cannot erase. -
[P1 availability] Concurrent transient loads supersede one another through the global per-identity attempt counter. Every
Fulltext2Search.Load, including one-shot transient loads, callsbeginLoadGeneration, which increments one sharedstate.attempt.loadGenerationCurrentaccepts only the latest attempt. A later independent MATCH therefore invalidates an older transient request even though neither is being globally published. Repeating ordinary overlapping requests before each retry can force one caller through all four coherence attempts and return retry exhaustion. Isolate transient bookkeeping, or safely serialize/share one transient load without letting unrelated callers invalidate each other. -
[P1 stale read] Fence fanout omits Draining CNs before they stop serving.
fencepublisher.nodesincludes only Working and Unknown work states. Draining begins asynchronous migration; the CN query service and existing or direct sessions can still be live. A CN with warmed generation G can enter Draining, be omitted from every broadcast retry for committed H, and serve G before its pull sweep. Include Draining nodes until their query address is withdrawn or establish a serving fence before excluding them.
These are current-code findings, not missing-CI gates. The exact-head direct-CN matrix is useful but does not schedule these three interleavings. Add deterministic regressions for prune versus paused transient load, overlapping transient attempts, and direct traffic on a Draining CN.
Q1 cleanup and Q3 bounded worker/registry behavior are improved on this head; I found no separate leak or unbounded-growth blocker. The unresolved stale-read and retry-livelock races violate the design terminal invariant and block approval.
|
( in pkg/vectorindex/cache). We can never clean the cache instantly in multiple CNs case. I don't think we need this mechanism. |
|
Closing this PR following the component owner's decision on #27788. Multi-CN FULLTEXT2 cache convergence is asynchronous by design, and the current product contract accepts a delay of several minutes. The 120-second threshold was a validation threshold, not a product SLA. Therefore the MORPC generation-fence mechanism introduced by this PR is not required and should not be merged. |
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27788
QA required: yes
What this PR does / why we need it:
FULLTEXT2 CDC tail commits previously invalidated only the consumer CN's process-local cache. A different CN could continue serving a warmed pre-commit generation.
This change:
Validation
Exact pushed head:
44b0803bdc64e1169fa60a603786bee3a5972abc, against PR base snapshotc46d897e9645b80178568ef0783dd8e99e527222.git diff --checkf2e91a01b56ccc7aeef3ac51ce93a478ea73d0a36338272353f037341b66971amo-servicebuildpr27806:44b0803-arm64, image IDsha256:68290448b5db2bbad5484e6cdb892bcb7395451f7cb3145f7cffe85cf4c9f586; extractedmo-serviceSHA25665ca8b42839dacf812a584de72a633a5d8f2a29902729c8321b324ff4915cea1fulltext2_bugfix.sqllifecycle BVT twice, each 58/58 cases with zero failures or abnormal exits33594034886attempt 2; SCA passed on Linux/arm64 after attempt 1 ended with self-hosted runner communication loss; all required checks passedHistorical results from older heads are not counted as exact-head acceptance.
Direct-CN exact-head evidence
pr27806-44b0803pr27806:44b0803-arm64, Linux/arm640:1; rollback stayed at0:10:2, UPDATE0:4, DELETE0:5, lost-RPC0:6, and sender-interruption0:7MATRIX_PASS; teardown:PASSQA Decision
MATCHafter CDC tail commit across independently serving CN processes