Repository navigation
IndexSearchScan for all index searches; remove the search TVFs (#27453) - #29746
Conversation
…rsion107 (matrixorigin#27453) VectorIndexScan becomes IndexSearchScan (VectorIndexTableRef -> IndexHiddenTableRef, query_vector -> query_payload, node type INDEX_SEARCH_SCAN) as the one access-path node for every vector and fulltext index. Field numbers are unchanged. The ivfflat-only fields 12-15 (initial_probe_count, first_round_limit, bucket_expand_step, threads_search) are reserved. Static algorithm settings travel in algo_options, encoded by the algorithm's planner and decoded by its reader (ivfflat.ScanOptions); row-dependent ones in named algo_exprs, folded or evaluated per row by vectorscan and handed to the reader as search.Request.AlgoValues. Shared code no longer reads ivfflat fields: local parallelism and distributed PRE ask the plugin (search.ParallelHooks.CanParallelize), EXPLAIN asks for the algorithm's settings (search.ExplainHooks), and expression walkers use IndexSearchScanExprs. MORPCVersion107 gates the contract: a pipeline carrying an IndexSearchScan, as a data source or in APPLY, requires 107 on its destination, and multi-CN placement fails when a worker is older. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…atrixorigin#27453) hnsw top-k plans as an INDEX_SEARCH_SCAN instead of a FUNCTION_SCAN of hnsw_search; the join on the primary key and the score sort are unchanged, and a provider row drives the search through CROSS APPLY as for ivfflat. The node carries the semantic k, the post-filter flag and the hnsw search threads in algo_options. pkg/indexplugin/search/planreader is the engine.Reader of an index search that produces ranked chunks through a Searcher, emitting the shared pkid/score/include schema. The hnsw Searcher runs one usearch search of the cached index (snapshot-keyed as before). Shared code keys on the algorithm's capabilities instead of on ivfflat: - search.CandidateBudgetHooks lets an algorithm size its post-filter budget; hnsw keeps overfetch.PostFilterLimit, ivfflat keeps FilteredPostModeLimit. - IndexSearchScanPartitioned (the plugin has ParallelHooks) gates the multi-CN placement and AP exec-type rules; an unpartitioned search plans and runs like the table function it replaces, in one local scope, and a small top-k stays TP. - resultColumnSourceFromIndexSearchScan resolves the shared schema of every algorithm. EXPLAIN shows "Vector Index Scan on <index>" for hnsw; the BVT regex assertions follow it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ed count When fewer rows pass (user filter AND NOT deleted) than the requested k, cuVS brute force and IVF-Flat fill the remaining result slots with excluded rows instead of sentinels, so a filtered query could return rows that fail its predicate and a soft-deleted row could reappear. Move IVF-PQ's host-side post-filter into gpu_index_base_t (apply_host_post_filter_locked / apply_host_mask_post_filter) and apply it in the brute-force and IVF-Flat search paths. A raw result position not set in the mask becomes (-1, FLT_MAX). It runs after the GPU search; the user-filter mask already carries the deletes, so only the deletes-only path takes a shared_lock. Tests: filtered and deletes-only searches with fewer allowed rows than k, for brute force, IVF-Flat, IVF-PQ and CAGRA. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
vector_ivfpq_ddl set kmeans_train_percent and ivfpq_max_index_capacity with SET. Session values reach only the CREATE INDEX build; they are not stored in algo_params, so the background REINDEX after ALTER TABLE ran with the default kmeans_train_percent (10%), trained on 2 of 20 rows and returned ties. The settings are now CREATE INDEX options, which every rebuild reads from algo_params. vector_cagra_ddl gets the same change for max_index_capacity. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
cagra and ivfpq sort rewrites now emit INDEX_SEARCH_SCAN instead of the cagra_search / ivfpq_search table functions. applyCuvsIndexSearchScan builds the shared shape: device filter JSON for INCLUDE / primary-key predicates, distance predicates on the search node FilterList, JOIN on pk, SORT on score. Static settings (threads, batch window, multi-GPU simulation, base column type, filter JSON, nprobe) ride algo_options. New search plugins (cagra/plugin/search, ivfpq/plugin/search) port the table functions' search: same veccache.Cache.Search call, index and table config, query-type and dimension checks, f16 decode and zero-limit default. The cuVS search is GPU-only (search_gpu.go); a CPU build returns NotSupported. Candidate over-fetch uses PostFilterLimit. scan_options.go of every vector index now lives in <algo>/plugin/plan; codecs use sonic. The ivfpq searcher keeps the table function's vector-type check and passes nprobe through tblcfg. TestRequiredIVFWorkersRequireProtocol107 pins gpu_mode off so it holds in GPU builds. GPU BVT explain assertions match "Vector Index Scan on". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n#27453) MATCH over a classic fulltext or a fulltext2 index now plans an INDEX_SEARCH_SCAN instead of the fulltext_index_scan / fulltext2_search table functions; EXPLAIN labels it "Fulltext Index Scan". The pattern is the query payload, the zero-relevance guard of a threshold known only at EXECUTE an algo expression, the pushed limit the candidate limit, and the static settings (table config, mode, INCLUDE/pk predicates, score range, source/index tables) ride algo_options. Stats are the table function's. Readers (port the table functions' search, unchanged in behaviour): - fulltext2 (pkg/fulltext2/plugin/search): SearchInto for a pushed limit, the streaming Emit producer otherwise, the self-completing json probe tail, INCLUDE columns by name. - classic (pkg/fulltext/plugin/search): the engine moved verbatim into Scan, shared with the direct-SQL fulltext_index_scan table function, which now only parses its arguments. Publisher reads route through the scan's source and index references. Framework: - A nil CandidateLimit is no limit; the query payload may be a string. - Statement-level scalars that ConstantFold leaves unfolded (a bare prepared parameter or user variable) are evaluated once. - EmptyScanHooks runs for a NULL query or a dropped runtime filter, so the guard and the pattern checks keep the table functions' order; Request.MembershipFilterPassed carries a PASSed membership filter. - engine.TableDefAt / SameTableSchema and fulltext.BuildMembershipFilter / CheckZeroRelevanceGuard move to shared packages. BVT: fulltext plan assertions match "Fulltext Index Scan on"; affected results regenerated. fulltext.result, fulltext_bm25.result and gojieba.result also record the current scores (e.g. 2.0, = 2*log10(10)^2 with 10 indexed documents); the stored ones were stale and passed only because mo-tester rounds to the coarser value's precision. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
) hnsw_search, cagra_search, ivfpq_search and fulltext2_search are no longer emitted by the planner; every index search runs through IndexSearchScan. Remove their plan builders, registrations, executors and tests, and the fulltext2 probe-tail remote fence. fulltext_index_scan stays for direct SQL. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…trixorigin#27453) Classic fulltext MATCH runs through IndexSearchScan, which carries the publisher identity on IndexSearchScan.SourceTable / HiddenTables, so the internal fulltext_index_scan TVF and its TableFunction fulltext_source_ref / fulltext_index_ref fields are dead. Remove the TVF, its planner builder and executor, and reserve the proto fields. The TVF's behavioral tests move onto the classic reader. pub_sub_fulltext asserts the function is not callable. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…pq (matrixorigin#27453) hnsw, cagra and ivfpq no longer run as table functions, so they join ivfflat in the early vector rewrite (LogicalSearchHooks.BuildLogicalSearch). A query with a MATCH filter and a vector Top-K now plans the vector search scan first and the fulltext rewrite then serves the MATCH on the same scan, so both indexes are used. The vector side post-filters its candidates. docs/design/20261008-index-search-scan.md records the as-built design of the issue proposal and the hybrid claims; vector_hybrid_fulltext(.sql, _gpu.sql) are the black-box tests for them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…er (matrixorigin#27453) hnsw, cagra and ivfpq only post-filter their candidates, so a selective MATCH returned fewer than k rows (0 of 3 on a MATCH keeping 4 of 200 rows). Like a membership join, a scan with a fulltext MATCH filter now admits only ivfflat; the others keep the exact sort over the fulltext hits, as before. Their early pass path stays behind the gate. The design doc and the hybrid BVT cases state and test the resulting behavior. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # pkg/defines/const.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the design gate at bb56c5afe8f059bfef0f4d759c076b6ca2393470, against current main d2a0055ebe1a0b2423368e046c1812c18f6face8. REQUEST_CHANGES: the design/acceptance contract needs closure before implementation approval.
This is a major architectural migration, not a mechanical rename: six algorithms move through new reader hooks and a changed wire node; five callable SQL search TVFs are removed, protobuf fields are retired, and GPU result filtering changes. The complete Git range contains 286 files (the PR metadata file list stops at 100). I read the versioned as-built design, the owning issue's full proposal/comments and its attached design, the review history, and the protocol/request/reader boundaries needed to establish scope. I have not claimed a full 286-file implementation review or runtime regression.
[P2] Close and record the design contract for the breaking migration. docs/design/20261008-index-search-scan.md is explicitly an as-built description. It explains the hooks, hybrid choices and new-to-old CN rejection, but neither it nor the original proposal closes:
- supported mixed-version operation in both directions, the intended availability/failure behavior during upgrade and rollback, and the migration/deprecation contract for stored/user SQL referencing the removed TVFs;
- the actual per-reader ownership and terminal sequence for partial initialization, cancellation, producer failure, early consumer exit and prepared reuse, including bounded no-LIMIT/probe-tail buffering and where those guarantees live after migration;
- measurable acceptance for the changed search hot paths. The original proposal explicitly requires ivfflat/fulltext2 filtered Top-K comparison against main; the PR reports functional/coverage/GPU tests but provides no corresponding benchmark result or explicit approved replacement for that requirement.
Please extend the stable versioned design with these decisions and their focused validation criteria/evidence, and link the exact design revision and a distinct design-review decision before resuming implementation approval. The earlier general APPROVE at a49603eb33 is acknowledged; its empty body does not identify a separate design decision or close the missing contracts above. This does not require a new RFC or a human-only review rule. It follows .agents/skills/mo-dev/references/feature-design-review.md for a cross-subsystem, public/wire/lifecycle refactor.
Accepted scope decisions: registry-based shared search dispatch is the right existing owner; avoiding a separate hybrid operator is sensible. I am not reopening the documented exact-sort fallback for HNSW/CAGRA/IVFPQ under MATCH, nor asking this PR to solve the pre-existing extra-JOIN/provider capability gaps. Consequently, not every issue-comment scenario is implemented; those remaining limitations are explicitly scoped out. There are no prior inline review threads. CI success is recorded, but it cannot establish an unspecified rollout/resource/performance acceptance contract.
Implementation, test, documentation and generated-code changes are inventoried separately; moves/deletions are not treated as proof of simplification. Detailed implementation/test-oracle closure remains pending the design gate, as required by the repository review workflow. No product code was modified and no subagent was used.
…of IndexSearchScan (matrixorigin#27453) The design doc records the decisions the design review asked for: no mixed-version operation in either direction and no fallback; no deprecation path for the removed search table functions; where each reader lifecycle guarantee lives and what covers it; no benchmark recorded. Status: awaiting design approval. A newer CN accepted an older coordinator's ivfflat node, whose reserved fields it dropped, unless an operator lowered the protocol version. The receiver now refuses an index search scan without algo_options, which every planner of this version sets. Black-box tests for the new claims: a two-CN cluster refuses an index search placed on a CN reporting an older protocol version and returns the exact rows once it is current; the removed functions fail directly and in CREATE VIEW; prepared ivfflat, hnsw, fulltext and fulltext2 searches return the reference rows at every re-execution. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rigin#27453) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…a test (matrixorigin#27453) Add black-box claims for the rank-mode clause and the join/provider scope, a unit test for a removed search table function reaching a newer CN, and narrow the statements no test covers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…vectorscan (matrixorigin#27453) Production code and tests refer to vectorscan.IndexSearchScanProtocolVersion, so a renumber before merge is a one-line change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…dexSearchScan (matrixorigin#27453) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
@XuPeng-SH thanks. The design gate is closed in Mixed version, upgrade and rollback (section "Compatibility and rollout"). Decision: mixed-version operation is not supported in either direction, and there is no fallback. Index search fails until every CN runs this version.
Reader lifecycle (section "Reader lifecycle"): partial initialization, cancellation, producer failure, early close, prepared reuse, and no-LIMIT / probe-tail buffering (channel capacity 4). Each item names its owner and the unit test that covers it, or "code review" where none does. Prepared re-execution is black-box tested (claim 9). Performance (section "Performance"):
New since your review: claim 10 (the rank-mode clause) and claim 11 (the extra-JOIN and provider shapes you scoped out), both black-box tested. Status: awaiting design approval from fengttt. |
…chScan (matrixorigin#27453) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Design phase reviewed at The versioned design now records both-direction mixed-version rejection and rollback behavior, removal of internal search TVFs without a compatibility path, reader owners and terminal paths, and concrete validation scope. I accept registry-owned search dispatch, composition of existing vector/fulltext rewrites, and the explicitly scoped exact-sort/provider/JOIN limitations. The original performance requirement has an explicit replacement decision: ported fulltext paths are compared against main; ivfflat keeps its search calls and gains once-per-reader option decoding. This is accepted as a scoped tradeoff, not a blanket performance guarantee. The unfiltered IVF-PQ benchmark does not establish the cost of the changed filtered/deleted-row post-filter, and its p99 does not show improvement. This records a distinct design review of |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep implementation review: REQUEST_CHANGES at b1a60cce33be53508a49f881da9a9efdd7adc032. Reviewed directly, without subagents.
The previous design-gate finding is closed by the updated contract and the separate design PASS. The registry/reader ownership direction is reasonable: generic execution dispatches through plugin hooks; algorithm options and folded expressions belong to their plugins; the existing APPLY/reader boundaries own per-query execution. This review has one remaining P2 finding: complete retirement of the replaced search-TVF budget/state/wire/test chain (inline).
Scope and engineering quality: the full Git range has 291 files, not the 100-file metadata preview. Production: 112 files, +3,653/-3,635; tests/results: 175 files, +9,789/-7,641; design documentation: 1 file, +256; generated protobuf: 3 files, +2,383/-2,611. I assessed those categories separately and traced renamed/moved readers back to the deleted TVFs; file movement is not counted as simplification. Reviewed planner gating/composition, prepared expression ownership, snapshot/subscription identity, partial reader initialization and cleanup, streaming cancellation/drain, APPLY reuse, protocol send/receive rejection, and the GPU result-mask/delete changes. The inline finding comes from following the retired responsibility chain past the new callers.
Validation on this head:
- Native CGo build passed. Complete local suites passed for classic fulltext search, fulltext2 search, shared planreader, HNSW search, and vectorscan.
- An additional reviewer-only MySQL-session test passed (19.646s): IVF/HNSW prepared execution across three query vectors, LIMIT/OFFSET changes, wrong-dimension failure followed by successful reuse, with an independent unindexed-table result oracle. Both fulltext variants passed prepared term changes, empty results, OFFSET and no-LIMIT count checks against known source rows.
- Targeted compile/protocol checks passed (1.383s), including older-sender refusal, APPLY, partition transport/rollback and empty-scan hooks. The two-CN SQL refusal/recovery test passed (10.950s).
- Required CI is successful at this exact head; the existing UT and BVT results were reused for broader coverage.
Performance/evidence boundary: no TP regression was demonstrated. Ordinary non-index-search TP queries do not enter the new reader or native result-filter loops. The GPU host recheck adds work proportional to returned query/candidate slots when a filter/delete mask is present. The author's unfiltered IVF-PQ benchmark does not measure that changed path; its p99 is also not a no-regression guarantee. Fulltext comparison data and the explicit absence of an ivfflat benchmark are recorded in the design. I did not run GPU binaries or performance benchmarks on this macOS CPU host.
Comment closure: the earlier rollout, removed-TVF, lifecycle and performance-contract questions now have explicit answers. Mixed-version rejection/no fallback and the documented hybrid/rank-mode/JOIN limitations are accepted scope decisions, not newly reported defects. The new cleanup finding remains open; implementation approval is withheld for that concrete design/test-quality issue.
…unction index state (matrixorigin#27453) The index search scan computes the candidate budget at execution (vectorscan + CandidateBudgetHooks / overfetch). Remove the planner's SQL over-fetch expression, IndexTableConfig.PostFilterOverFetch, the table-function operator's IndexReaderParam/RuntimeFilterSpecs with their encode/decode (pipeline.TableFunction fields 7 and 8 reserved), and the FUNCTION_SCAN LIMIT stats branch. Cover the budget at the request boundary. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With lists=5 over 21 rows, GPU (cuVS) k-means can leave an empty centroid nearest the query, so the nprobe=1 POST search returns nothing and the case's analyze assertion fails on GPU builds. Two lists separate the near cluster from the far row, which is the shape the case describes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
aunjgr
left a comment
There was a problem hiding this comment.
APPROVE the documented IndexSearchScan migration at e8d49ec against declared base/merge-base d2a0055. No confirmed blocker in the reviewed design/reader/protocol and retirement boundaries.
The separate design PASS at b1a60cc closes the previously reported contract gate; I verified that decision rather than treating an empty general approval as the design artifact. The current document's awaiting-approval line is stale relative to that technical design disposition; the separately requested maintainer approval is not impersonated by this review.
Reviewed the shared request/reader ownership, execution-generation cleanup, fulltext streaming/tail cancellation owners, publisher/snapshot identity, empty-scan hook and partial parallel-reader cleanup boundaries. Registry-owned dispatch and existing APPLY/engine-reader owners are appropriate; hybrid composition does not add a separate state machine. Checked the latest retirement increment against its replacement consumers: removed TVF budget construction/state/encoding/statistics and old tests are replaced by runtime candidate-budget and prepared-limit boundary controls. Pipeline fields7/8/9/10 and names are reserved; no legacy state is forwarded through ordinary table functions. The extreme/zero/prepared limits retain their saturating budget semantics.
Evidence reused: exact-head required CI, including native-build jobs, UT/SCA/coverage and proxy/pessimistic BVT is green. The author and prior implementation review supply public prepared/reuse, protocol refusal, hybrid/publication and reader tests; those runtime runs are not represented as my own execution. This pass is focused independent verification of the contracts and current retirement delta, not exhaustive recertification of every hunk in the approximately290-file migration. No fresh native GPU, SQL cluster or performance run was executed locally. Diff whitespace reports trailing spaces in generated fulltext result lines; this is nonblocking fixture formatting, not a correctness finding.
Accepted limits remain explicit: no mixed-version availability/fallback, removed SQL TVFs have no migration path, HNSW/CAGRA/IVF-PQ use exact sorting under MATCH, and additional JOIN/provider shapes remain outside scope. The unfiltered IVF-PQ benchmark does not validate the changed filtered/deleted-slot host pass or establish a p99 improvement; no broader GPU/performance guarantee is made.
# Conflicts: # pkg/defines/const.go # pkg/sql/plan/apply_indices_cagra.go # pkg/sql/plan/apply_indices_ivfpq.go # pkg/sql/plan/coverage_regression_test.go # test/distributed/cases/fulltext/fulltext.result # test/distributed/cases/fulltext/fulltext_bm25.result # test/distributed/cases/fulltext/gojieba.result
…atrixorigin#27453) Main's matrixorigin#29147 case asserted the removed hnsw_search table function; on this branch HNSW searches through IndexSearchScan. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
mo-bot review · Commit: Assessment: needs_validation 职责归属与统一 reader 的设计合理,历史两条评审意见已闭环。未确认本次引入的具体代码缺陷;GPU 验证证据尚不足,不能判定通过。 Model: Session: Validation:
Limitations:
|
Merge Queue Status
This pull request spent 1 hour 9 minutes 14 seconds in the queue, with no time running CI. ReasonThe merge conditions cannot be satisfied due to failing checks
HintYou may have to fix your CI before adding the pull request to the queue again. Waiting for any of
All conditions
Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 5 minutes 57 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
# Conflicts: # pkg/defines/const.go
Merge Queue Status
This pull request spent 29 minutes 15 seconds in the queue, with no time running CI. ReasonPull request #29746 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.
HintYou 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. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #27453
What this PR does / why we need it:
Every index search (ivfflat, hnsw, cagra, ivfpq, fulltext2, classic fulltext) now plans and executes through one plan node,
IndexSearchScan, instead of per-algorithm table functions.IndexSearchScancarries per-algorithmalgo_options(JSONScanOptionsunder<algo>/plugin/plan), namedalgo_exprs, a query payload (vector or string), a candidate limit, and the source/hidden-tableObjectRefs. A dedicated MORPC protocol version gates the wire change, one bump for all six index algorithms; remote dispatch to an older CN fails instead of misreading the plan.<algo>/plugin/search) behindsearchpluginhooks (NewReader, parallel, explain, candidate budget,EmptyScan). The readers are ported from the TVF executors, preserving the TVFs' search behavior (SearchInto, streaming, probe tail, guards).Vector Index Scan on <idx>orFulltext Index Scan on <idx>; BVT plan directives and results are updated.IndexSearchScan.SourceTable/HiddenTables, soTableFunction.fulltext_source_ref/fulltext_index_ref(fix: support fulltext scans over publications #26702) are removed and their proto field numbers reserved.hnsw_search,cagra_search,ivfpq_search,fulltext2_searchandfulltext_index_scanare removed with their builders, executors and tests; they are no longer callable from SQL.*_create,fulltext2_compactandfulltext_index_tokenizeare unchanged.Hybrid queries that combine a fulltext MATCH with a vector ORDER BY on the same table plan as a fulltext scan joined with a vector scan, with the fulltext side runtime-filtering the vector side (verified for classic fulltext and fulltext2 with ivfflat). The hybrid shapes reported in the issue comments (fulltext + HNSW with a constant, fulltext2 + ivfflat + an extra join) are planner capability gaps that predate this change and are out of scope here.
Tests
fulltext.sql: the stored TF-IDF score 1.6311431 was stale; the correct score is 2.0 (reproduced by running the EXPLAIN VERBOSE SQL). mo-tester rounds float comparisons to the coarser precision, which is why the stale value passed on main.🤖 Generated with Claude Code