Skip to content

feat(ivfflat,fulltext2): ignore and record rows the index cannot store (#31583) - #32096

Merged
mergify[bot] merged 25 commits into
matrixorigin:mainfrom
cpegeric:issue_31583_ivfflat_fulltext2
Nov 9, 2026
Merged

mergify[bot] merged 25 commits into
matrixorigin:mainfrom
cpegeric:issue_31583_ivfflat_fulltext2

Conversation

@cpegeric

@cpegeric cpegeric commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #31583 (IVF-Flat and FULLTEXT2; completes the issue after #32036)

What this PR does / why we need it:

IVF-Flat and FULLTEXT2 now follow the ignored-rows contract HNSW, CAGRA and IVF-PQ follow (docs/design/20261028-index-ignored-rows.md): MAX_BAD_RECORDS, the hidden ignored table, SHOW INDEX IGNORED / SHOW INDEX STATUS, a permanent stop past the limit, REINDEX restarting it. Before this change one row such an index cannot store failed the build or the statement, and on an asynchronous index stopped every later sync.

IVF-Flat (decided by @cpegeric: the check and the recording live in product_l2; the cast stays in SQL)

  • What cannot be stored: an element beyond the range of the QUANTIZATION type, an int8/uint8 code that is not finite, a squared L2 norm beyond max/4 of the distance type, a NaN or infinite element. One check, ivfflat.Storage, serves product_l2, the k-means samples and the search.
  • product_l2 leaves out and records such rows in every path that assigns rows to centroids: the build, the async build and its sync, REINDEX, restore, and DML on a synchronous index. The index reaches it as JSON on CENTROIDX(optype, params, config) (the catalog row does not exist yet during CREATE INDEX); only internal SQL may pass that form.
  • DML on a synchronous index follows MAX_BAD_RECORDS (decided by @cpegeric): within it the row is recorded, past it the statement fails. The count is the one the statement's transaction sees (decided by @cpegeric, 2026-11-04): concurrent transactions may together commit past the limit, by at most the rows each could add; every later statement that records a row then fails until rows are fixed or REINDEX runs. A lock serializing them was rejected (it serializes bad-row DML and adds a lock the DML path does not take). Deleting a row, or updating it to a value the index stores, removes its record, in DML and in the sync.
  • k-means skips the samples the index cannot store; fewer good samples than lists seed one NULL centroid, as a table with fewer rows does. A query vector the index cannot store is rejected.

FULLTEXT2 (new reason codes, decided by @cpegeric)

  • Text the json parser cannot parse (20351) and a DATALINK that cannot be read (20352: missing stage or file, unsupported url, text that cannot be extracted) are recorded with their message in the new reason column, in the build and the sync. Timeouts, lost connections and unreachable endpoints are retried; a local source for an asynchronous index stays an error, since it is a setting of the table.

Keys read as users see them: a composite key as (a, b), an ENUM key as its member, in SHOW INDEX IGNORED and in the stop messages. An index created before this change has no ignored table and keeps its SQL; its bad rows now carry the new codes.

The design doc gains IVF-Flat and FULLTEXT2 sections and claims I15–I20, each with unit tests and a section of pessimistic_transaction/vector/vector_ivfflat_ignored.sql or pessimistic_transaction/fulltext2/fulltext2_ignored.sql.

Known limit: an ENUM part of a composite key shows its number in the stop message (SHOW INDEX IGNORED shows the member).

Validation

  • BVT (CPU, fresh instance, -g -n): vector_ivfflat_ignored.sql 71/71, fulltext2_ignored.sql 31/31; vector 3505/3507 (2 ignored), pessimistic_transaction/vector 1156/1198 (42 ignored), fulltext2 1374/1374, pessimistic_transaction/fulltext2 passing. Eight existing .result files list the new hidden ignored table.
  • DATALINK from a remote stage (not reachable from BVT) checked live against a MinIO stage, build and sync: a missing file is recorded with stage://ms/missing.txt: file ftdocs/missing.txt is not found.
  • Unit: every touched package passes, including pkg/sql/plan, pkg/sql/compile, pkg/iscp, pkg/sql/colexec/productl2, pkg/sql/colexec/table_function, pkg/vectorindex/..., pkg/fulltext2/...; the new tests pass -race -count=30. golangci-lint: 0 issues.

🤖 Generated with Claude Code

cpegeric and others added 2 commits November 3, 2026 15:42
IVFFLAT and FULLTEXT2 now leave out the rows they cannot store, record them
in the index's ignored table, and stop past MAX_BAD_RECORDS, as HNSW, IVF-PQ
and CAGRA do. SHOW INDEX IGNORED and SHOW INDEX STATUS cover both.

IVFFLAT
- product_l2 checks each probe row against the entry type (QUANTIZATION
  range, int8/uint8 code, squared norm, non-finite) and records the rows it
  leaves out; the index reaches it as JSON on CENTROIDX, which only internal
  SQL may pass.
- k-means sampling skips such rows; too few samples seed one NULL centroid.
- Synchronous DML follows the limit; the async sync records and removes
  rows by key; a query vector the index cannot store is rejected.

FULLTEXT2
- Text the json parser cannot parse (20351) and a DATALINK that cannot be
  read (20352) are recorded with their message; transient errors retry.

Keys read as users see them: composite keys as (a, b), ENUM keys as their
member, in SHOW INDEX IGNORED and in the stop messages.

issue matrixorigin#31583

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 →

@cpegeric

cpegeric commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in 84982fc. A composite primary key is now the hex literal of its serial, X'…', in SHOW INDEX IGNORED and in the errors of the limit. The text form lost fractional seconds and could not be compared with the key. The literal is exact, so WHERE serial(a, d) = X'…' finds the source row, and a join on serial(...) matches a table of saved keys. The per-part scale plumbing is removed. The design doc records the format (claim I21).

vector_ivfflat_ignored.sql adds two DATETIME(6)/TIME(6) keys in the same second: they show distinct literals, and the literal finds its row.

Validation:

  • BVT: vector_ivfflat_ignored.sql 108/108, fulltext2_ignored.sql 31/31, vector_hnsw_ignored.sql 150/150, GPU vector_cuvs_ignored.sql 173/173.
  • pkg/sql/plan, pkg/iscp, pkg/vectorindex and the GPU test packages pass. The GPU-only TestCuvsIgnoredRowsLimit now expects the reason column.

cpegeric and others added 3 commits November 5, 2026 20:50
The reason of a row the index cannot read held the whole error message,
which carries the malformed JSON document, so a value near the column
length overflowed the VARCHAR(65535) reason column and failed the build
or the sync it was allowed to skip. The reason is now at most 1024 bytes,
cut at a character boundary, with invalid UTF-8 replaced.

The GPU session-vars case lists the ignored table an IVF-PQ index has.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XuPeng-SH

XuPeng-SH commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · superseded

Commit: cb6c3e204342899a58c8d3d8fcce9cef210feaf3

Review belongs to an older commit; it is not a review of the current head.

@XuPeng-SH

XuPeng-SH commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 588ef78d073c8e1123b2352a14c724a663b02914

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: 588ef78d073c8e1123b2352a14c724a663b02914

Assessment: approve

The design coherently reuses existing admission, ignored-row and ISCP owners. Prior blocking concerns are resolved; transaction-visible quota enforcement remains an accepted design choice.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed all 83 changed files, all 55 discussion entries and linked issue 31583; saved the review map, plan, discussion ledger and source assessment.

  • Local checks passed: preflight, exact parser regeneration/comparison, protobuf descriptor audit, Go1.27.1 parsing/gofmt of 69 files, and vectorindex internal-test import graphs under CPU/gpu tags. Receipts and retained logs match; source remains unchanged.

  • Frozen exact-head CI reports successful shared build, UT/SCA/coverage, PROXY and PESSIMISTIC BVT, and CI Required.

Limitations:

  • No local product tests, live SQL/CDC probes or GPU execution. Raw CI selections/logs are unavailable; older author runtime reports are corroborating evidence only.

  • All-bad composite build errors can still print raw serialized key bytes; this is a nonblocking diagnostic inconsistency.

@cpegeric

cpegeric commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@aunjgr @iamlinjunhong please review the PR. thanks

@XuPeng-SH

XuPeng-SH commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 588ef78d073c8e1123b2352a14c724a663b02914

New discussion was assessed; the previous review remains unchanged.

@iamlinjunhong iamlinjunhong 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.

Reviewed exact head 588ef78d073c8e1123b2352a14c724a663b02914 against main at 57e7871e500e6e3d35fd352a092ee41b03a979fc, within issue #31583's IVF-Flat/FULLTEXT2 ignored-row scope. No remaining in-scope findings were confirmed; APPROVE.

Previous feedback is reconciled. The composite temporal-key display issue now uses the complete serialized key as a hex literal, preserving fractional seconds and ENUM ordinals; the SQL regression distinguishes same-second keys, filters the displayed key, and finds its source row. The author explicitly replied. FULLTEXT2 recorded reasons are now bounded to 1024 bytes at a UTF-8 character boundary, with build/sync regression coverage and a direct author reply. Earlier empty-sample, FK reinsertion, dotted-identifier, GPU import, non-finite quantization, ENUM replay and spill-cleanup fixes remain present. Transaction-visible quota enforcement remains the accepted scope decision.

Validation: inspected the complete change set and relevant build/DML/sync/search consumers; checked the generated parser's semantic-action delta and verified that the protobuf descriptor adds only ProductL2.ignored string field 6. The read-only PR artifact check passed. Local Go/SQL/race/GPU tests were skipped because source analysis resolved the review questions; supplied CI conclusions and author test reports were reused within their stated scope, without claiming local runtime reproduction. Source files were unchanged.

CI snapshot: the 29 checks are not all successful: 13 success, 14 skipped and 2 neutral; none failed or pending. CI Required passed. Failed-check investigation was skipped because the supplied snapshot contains no failed checks.

@XuPeng-SH

XuPeng-SH commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 588ef78d073c8e1123b2352a14c724a663b02914

New discussion was assessed; the previous review remains unchanged.

cpegeric and others added 3 commits November 6, 2026 19:52
# Conflicts:
#	pkg/pb/pipeline/pipeline.pb.go
Conflicts: pipeline.pb.go and mysql_sql.go regenerated from the merged
proto and grammar; ivf_create.go keeps the branch's ivf_getVersion seam
and nil-sample guard with main's admitted policy.

main's index-maintenance admission (matrixorigin#32032) did not cover the fulltext2
ignored table this branch adds: fulltext2_create wrote it without a
policy, from a name in its SQL-supplied config. fulltext2_create now
admits the ignored table as a target, writes it under the policy, and
the planner's maintenance roles and validation include it
(fulltext2.MaintenanceOperands). Tests updated for the admission.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in merge

main's matrixorigin#32032 added TestHiddenIndexUserAccess and vector_ivf_clone_sync
counts of physical index tables. With this branch, IVF-Flat and FULLTEXT2
also own an ignored-row table, so each group has 4 tables (was 3) and the
clone_sync table has 8 physical tables (was 6).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XuPeng-SH

XuPeng-SH commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: bdb65a2ac2165d8df8c9123a952901bf9fb25650

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: bdb65a2ac2165d8df8c9123a952901bf9fb25650

Assessment: request_changes

The shared ignored-row design is coherent, and earlier findings are resolved. One regression remains: transient AWS S3 failures can permanently omit valid FULLTEXT2 documents.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

  • P2 pkg/fulltext2/ignored.go:42: An AWS-backed DATALINK read exhausts its SDK retries with HTTP 429 or 503 during FULLTEXT2 build or CDC.
    Impact: The error becomes ErrIndexDatalink. Within MAX_BAD_RECORDS, CDC omits the valid document and advances its watermark, so endpoint recovery does not retry it; without allowance, maintenance stops permanently. Extend the existing retry classifier to recognize AWS throttling/server errors before this permanent fallback, with provider-specific regression coverage.
    Evidence: The exact-source component probe in provider-probe.log (receipt checks/1794081368127428496-4.json) shows AWS SDK retryable=true but IsRetryableStartupError=false for both statuses, while MinIO equivalents return true. AwsSDKv2.Read/mapError preserves these errors; FULLTEXT2 records them through fulltext2_sqlwriter.go and commits ignored rows with the watermark in fulltext2_consumer.go:123. This violates the transient/throttling retry contract in docs/design/20261028-index-ignored-rows.md:225.

Validation:

  • Reviewed the complete delta and affected consumers; reconciled all 61 discussion keys in discussion-assessment.json.

  • Isolation preflight passed; the provider component probe confirmed the AWS/MinIO classification discrepancy.

  • MySQL parser regenerated byte for byte; complete protobuf descriptor comparison found only ProductL2.ignored field 6.

  • Static CPU/GPU repository import closures passed for eight affected package roots, including internal tests.

  • Six current-head check receipts reconciled with retained evidence; source remains unchanged.

  • Frozen CI snapshot reports 13 successful, 14 skipped and 2 neutral checks.

Limitations:

  • The provider probe uses exact helper bodies and pinned direct SDK versions under Go 1.26.6; no live S3 or public SQL reproduction was run.

  • Full native CPU/GPU suites were not run locally. Frozen CI lacks individual test logs; author GPU/race results remain attributed historical evidence.

…r fails

The retry classifier read the HTTP status only from MinIO errors, so an AWS,
Aliyun OSS or Tencent COS response of 408, 429 or 5xx that the SDK stopped
retrying was taken as a datalink the index cannot read, and its row was left
out. It now reads the status from every object-storage SDK.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cpegeric

cpegeric commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the finding of the review of bdb65a2ac2 in c30de14794:

  • pkg/fulltext2/ignored.go:42, AWS throttling taken as a permanent DATALINK failure. fileservice.IsRetryableStartupError read the HTTP status only from minio.ErrorResponse. It now reads it from the AWS SDK (any error with HTTPStatusCode(), such as awshttp.ResponseError inside smithy.OperationError), MinIO, Aliyun OSS and Tencent COS. As before, 408, 429 and 5xx are transient, so DatalinkError returns the error unchanged and the build or CDC retries it rather than recording the row as ignored. This is the contract in docs/design/20261028-index-ignored-rows.md. On main the function has no other non-test caller.
  • Tests:
    • TestIsRetryableStartupErrorTypedFailures adds AWS 429 and 503 (transient), AWS 403 (not), OSS 503 and COS 503.
    • TestDatalinkError adds an AWS 503 that must come back unchanged.
    • The AWS and OSS cases fail on the previous classifier. COS 503 was already transient through IsRetryableError.

Validation: pkg/fileservice and pkg/fulltext2/... pass; vet and gofmt are clean.

@XuPeng-SH

XuPeng-SH commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: c30de147943caed6faf91e42e2c11c24b6ee54ed

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: c30de147943caed6faf91e42e2c11c24b6ee54ed

Assessment: request_changes

Existing ignored-row and ISCP reuse remains coherent. The AWS 429/503 cases are fixed, but one retryable API-code case still causes permanent omission of valid FULLTEXT2 documents.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

  • P2 pkg/fileservice/error.go:108: An AWS-backed DATALINK read exhausts SDK retries with HTTP 400 and API code RequestTimeout during FULLTEXT2 build or CDC.
    Impact: The status check and network fallbacks return false, so DatalinkError converts this transient failure into ErrIndexDatalink. Within MAX_BAD_RECORDS, the document is omitted and CDC can advance its watermark without retrying it after endpoint recovery. Recognize retryable provider API codes alongside HTTP statuses, while retaining permanent-error controls.
    Evidence: The pinned AWS SDK v1.41.5 explicitly treats RequestTimeout as retryable; aws-retry-oracle.log confirms this for the wrapped HTTP 400 error. Source tracing finds no matching project classifier branch. AwsSDKv2.mapError preserves non-404 errors; fulltext2/ignored.go:37 classifies this error as permanent, and fulltext2_consumer.go:125-139 commits ignored rows with the watermark. See source-assessment.md and validation-ledger.json.

Validation:

  • Reviewed all 89 paths, affected consumers, 64 discussion entries and linked issue context; discussion coverage is complete.

  • Preflight passed. Parser regeneration matched byte for byte; complete protobuf comparison found only ProductL2.ignored field 6. All 74 changed Go files passed parsing and formatting checks.

  • Pinned AWS SDK oracle passed under Go 1.26.6 with -race and transient/permanent controls. Project classification is source-confirmed.

  • Reconciled eight receipts with retained logs; source remains unchanged. Reused applicable prior coverage, frozen-head CI conclusions and attributed author reports.

Limitations:

  • The broader provider probe timed out fetching dependencies twice; neither attempt executed its tests.

  • No local Go 1.27/native product suite, live S3/SQL or GPU execution. Raw CI and author runtime logs were unavailable.

IsRetryableStartupError read only the HTTP status of an object-storage
error, so an AWS RequestTimeout (HTTP 400) or Throttling response was
classified as permanent and FULLTEXT2 recorded the DATALINK row as
ignored. It now also reads the API error code from AWS, MinIO, OSS and
COS errors and treats the codes in the AWS SDK's default retryable and
throttle sets as transient.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XuPeng-SH

XuPeng-SH commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 9137c239da7b30cf4ed6a2658c2bc099d7919ce6

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: 9137c239da7b30cf4ed6a2658c2bc099d7919ce6

Assessment: approve

The feature coherently reuses existing admission, ignored-row, spill and ISCP owners. Earlier findings are resolved, including AWS RequestTimeout classification; transaction-visible quotas remain the accepted design.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed all 89 changed paths, affected consumers, linked issue context and 66 discussion entries; saved complete review and discussion ledgers.

  • Preflight passed. Parser regeneration byte-matched; protobuf comparison confirmed only ProductL2.ignored field 6. All 74 changed Go files passed parsing/formatting; affected CPU/GPU static import checks passed.

  • Exact-source provider component tests passed with -race -count=1 through test-exec, including AWS retryer and permanent-error controls. Eight receipts and retained logs are reconciled in validation-ledger.json; source remains unchanged.

  • Frozen-head CI: 13 successful, 14 skipped and two neutral checks, including build, UT, SCA, coverage and both active multi-CN BVT lanes.

Limitations:

  • The component probe used Go 1.26.6; no local native product suite, SQL/CDC, live cloud or GPU-device execution. Raw CI selections/logs and historical author runtime artifacts were unavailable.

  • The previously accepted raw composite sample-key rendering in synchronous all-bad-build errors remains a nonblocking diagnostic inconsistency.

@aunjgr aunjgr 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.

Independent re-review at 9137c23, following the separately recorded design PASS. The earlier quoted-PK lookup, non-finite integer quantization, fatal-path spill cleanup and oversized ignored-reason findings are resolved. Reasons are now bounded to 1,024 bytes without splitting UTF-8; tests cover large ASCII/multibyte input and public CREATE plus asynchronous sync recording.

I checked the current integration delta, including lossless composite-key hex literals, FULLTEXT2 ignored-table maintenance admission, and typed object-storage retry classification. The documented transaction-snapshot quota and possible concurrent aggregate overshoot remain accepted semantics, not an exact global quota guarantee. No remaining actionable implementation blocker was found.

Evidence reused: current-head successful build, UT, SCA, coverage and both active BVT lanes, with scoped author CPU/race/SQL results. No new local execution is claimed.

Non-blocking description correction: the PR body still describes composite keys as (a, b) and lists the old ENUM-part display limitation. The current code and versioned design instead use lossless X'...' serialized-key literals; align that summary before using it as the commit message.

# Conflicts:
#	pkg/iscp/index_sqlwriter.go
#	pkg/pb/pipeline/pipeline.pb.go
#	pkg/sql/parsers/dialect/mysql/mysql_sql.go
#	pkg/sql/plan/bind_insert.go
@mergify

mergify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as ac22410 at 13:57 UTC

2 h 23 min in the queue, 1 h 14 min of it CI.

So far

  • ✅ Entered the queue Mon 9 Nov, 11:34 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 13:57 · ac22410 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 663cf831 Deployed Nov 9, 2026 by mergify[bot]
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 kind/documentation Improvements or additions to documentation kind/feature kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants