Skip to content

update - #7

Merged
cpegeric merged 1 commit into
cpegeric:iscp_finalfrom
jiangxinmeng1:iscp_final
Oct 16, 2025
Merged

cpegeric merged 1 commit into
cpegeric:iscp_finalfrom
jiangxinmeng1:iscp_final

Conversation

@jiangxinmeng1

Copy link
Copy Markdown

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #

What this PR does / why we need it:

@cpegeric
cpegeric merged commit ea6a29f into cpegeric:iscp_final Oct 16, 2025
cpegeric added a commit that referenced this pull request Jun 3, 2026
… post-filtering)

The exact-PK (mode=pre, small key set) entries query had "ORDER BY vec_dist
LIMIT k" added, which regressed vector_ivf_mode.sql.

Root cause (reproduced in pure SQL + EXPLAIN against the entries table): adding
"ORDER BY vec_dist LIMIT k" makes the planner push the sort+limit INTO the
entries Table Scan -- EXPLAIN shows "Index Reader Param: Sort Key ... Limit: k"
on the scan node. That applies the LIMIT *before* the "pk IN (...)" / prefix_eq
filter, turning our intended pre-filter into a POST-filter: it takes the global
top-k by distance over ALL entries, then keeps only the candidates, so fewer
than k matching rows survive. E.g. candidate set {1,2,7} with LIMIT 3 returns
{1,2} -- the global top-3 by distance is {1,2,5}, and pk 7 (rank #7) never makes
the cut. Without ORDER BY/LIMIT the scan stays a plain filtered read (no Index
Reader Param) returning the full candidate set, and the downstream
Node_SORT + LIMIT k does the ranking and truncation.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cpegeric added a commit that referenced this pull request Jul 6, 2026
Resolve four findings from the WAND retrieval-index self-review:

- B1 uuid membership prefilter: docFilterMembership.Contains probed a uuid via
  encodePk (36-char canonical string), but the membership filter is built from
  the source uuid's raw 16 bytes (CBloomFilter.addFixedVector) — every candidate
  was rejected, so a uuid-PK retrieval query with a WHERE prefilter returned zero
  rows. Probe the raw 16 bytes to match. (Native temporal/decimal PKs were already
  correct: their encodePk output IS the raw representation the bloom hashes.)
- #4 cfg JSON: build the WAND search TVF config with json.Marshal instead of raw
  fmt.Sprintf, so a schema name containing a quote/backslash no longer produces
  malformed JSON that the search side's Unmarshal rejects.
- #5 retrieval fail-fast: a parser='retrieval' index is maintained only as WAND
  frames (classic postings go stale), so error instead of silently falling back to
  fulltext_index_scan when its WAND store/metadata siblings can't be resolved.
- #6 CDC-blob bounds check: readLenBytes/readLenString bounds-check the length
  against remaining bytes + io.ReadFull, so a truncated pk/text errors cleanly
  rather than silently zero-filling.

Regression tests: TestDocFilterMembershipUuid, TestDecodeWandCdcTruncatedPk.

Decision-logged (not fixed): B2 (limit/offset, skipped per request); B3 (insert+
delete-same-window phantom — needs reachability confirmation + a coalescing change
that provably preserves the working UPSERT ordering); #7/#8 (dead parallel codecs
entangled with live helpers — dedicated cleanup); #9 (hot-path micro-opt, low gain).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cpegeric added a commit that referenced this pull request Jul 16, 2026
…e base

Five self-review findings on the CDC/rebuild paths:

#1 CDC pk-type panic — the fulltext2 sink binary-encodes the pk (encodePk asserts
native Go types), but IndexConsumer.valueRepr only gave *WandSqlWriter ReprNative;
*Fulltext2SqlWriter got ReprSQLString, so a datetime/time/timestamp/decimal/uuid pk
arrived as its SQL-display string → interface-conversion panic crashed the consumer
goroutine → index permanently unmaintained. Fix: add *Fulltext2SqlWriter to the
native-repr writers.

#3/#4 json CDC produced ZERO tokens (rows silently unsearchable) — build (rowTerms)
flattens each json column per-column, binary-aware, then joins; CDC joined the raw
columns then flattened the blob once with binary=false, which mis-parsed a T_json
column (bytejson.ByteJson) and multi-column json. Fix: flatten per-column on the
CDC write side (FlattenJSONColumn, type-dispatched: ByteJson vs text-json) exactly
like build, and CdcTokenizer no longer re-flattens.

#6 REBUILD over an emptied table served the stale base — the create TVF clears the
tag=0 base inside end(), but end() early-returns on zero source rows, so a rebuild
of an all-deleted table kept the old base. Fix: clear the base(s) + evict the cache
in the REBUILD orchestrator (buildAndRegisterCDC), which has the cfg regardless of
row count.

#7 stale doc comments (fulltext2_search.go "no VectorIndexCache yet"; search_cache.go
"off-heap posting buffers" — now mmap block-postings).

BVT: pessimistic_transaction/fulltext2/fulltext2_bugfix (datetime+decimal PK CDC,
T_json + multi-column json CDC, REBUILD-empty), validates 100%. Live-verified all
four. (#5 multi-segment boolean stats/top-k is the remaining open finding.)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cpegeric added a commit that referenced this pull request Jul 21, 2026
… of 7)

Self-review (fulltext2_only vs cuvs_quantize, OOM focus) surfaced 7 defects; this
fixes 6:

#1 (BLOCKER, index.go) newBoundedTopK did make([]topKItem,0,k) — a pushed LIMIT
(clamped to MaxInt32) sized the phrase top-k to ~50GB and OOM-killed the CN on a
tiny table. Now: no pre-alloc (grow lazily to min(k,#matches)) + cap k to globalN in
SearchPhrase. Verified: MATCH ... LIMIT 500000000 on a 3-row table returns instantly.

#2 (BLOCKER, plugin/plan/tablefunc.go) fulltext2SearchColDefs declared
doc_id=T_int64/score=T_float64 but the executor AppendAny/AppendFixed[float32] — a
direct FROM fulltext2_search(...) wrote 4-byte floats into an 8-byte score column
(garbage ORDER BY) and mistyped non-int pks. Match the executor (T_any / T_float32),
same as the MATCH-path ftIndexColdefs.

#3 (index.go) ReconstructLiveDocs bucketed the WHOLE live corpus before yielding, so
MERGE (guard-exempt) peaked at O(corpus) Go heap — the reclaim op itself OOMs. A live
doc's postings are entirely within its own segment, so reconstruct ONE SEGMENT AT A
TIME: buckets is now bounded to O(one segment) (≤ capacity), freed before the next.

#4 (storage.go) checkTailLoadBudget gated on 1× SUM(LENGTH(data)) but load holds raw
chunks + reassembled frames + decoded segments at once; scale the estimate (×3) so the
guard fails before the real peak OOMs.

#6 (segment.go, termdict.go) loaded-side forEachPosting materialized the whole
vocabulary via prefixTerms("") ([]string); stream the FST via a new forEachTerm — no
O(vocabulary) spike compounding the MERGE peak.

#7 (serialize.go) decodeDocmap stored pk offsets in []int32; a >2GB docmap wrapped the
offset negative → pk(ord) panic. Fail fast at decode instead.

Deferred/decision-logged: #5 (stream.go:143 no-LIMIT non-disjunctive materializes all
matches) is partially mitigated by #1 (phrase pre-alloc now bounded to #matches); the
full fix is DAAT streaming for phrase/boolean (A2), bounded by the result set the user
asked for.

Verified: pkg/fulltext2 tests pass; live MERGE 25/25, fulltext2 37/37, membership
33/33, async 18/18; build/vet/gofmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants