Repository navigation
Conversation
…rigin#25000) REPLACE into a table carrying an irregular index (ivfflat vector index or fulltext index) succeeded but did not maintain the index, so a row inserted or whose indexed value changed via REPLACE was not reflected in a subsequent index-backed ANN/KNN or MATCH...AGAINST query until the next cron reindex. The modern operator-based REPLACE path stripped irregular indexes via getValidIndexes and relied on async maintenance. This restores synchronous maintenance for non-async ivfflat and fulltext indexes: - Collect the non-async ivf / fulltext index defs before they are stripped. - Sink the processed new rows once (tag-preserving SINK_SCAN) so auto-increment / generated columns are evaluated a single time and shared by the main conflict-resolution branch and the index-maintenance sub-plans. - Build the index sub-plans AFTER createQuery (like the legacy insert path): they use positional column refs and must not go through the per-step optimize/remap pipeline; finalize only the new steps via handleHashMapMessages. - ivf: insert entries for every incoming row and delete the stale entries of conflicting rows (a PK conflict's new PK equals the replaced row's PK, so the old entry keyed by org_pk is removed; a brand-new PK matches nothing). - fulltext: a single POSTDML node per index deletes the stale inverted entries (by doc id = incoming PK) and re-tokenizes the new rows. Regular tables and regular secondary indexes are unaffected. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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? |
The result files in the previous commit were regenerated against a stale mo-service binary and captured the pre-fix (buggy) behavior. Regenerate them against the fixed build so they reflect synchronous index maintenance: ivf KNN now returns the newly REPLACE'd row and drops stale vectors, and fulltext MATCH now sees the new tokens and drops the replaced row's stale ones. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #25000
What this PR does / why we need it:
REPLACEinto a table carrying an irregular index (ivfflat vector index or fulltext index) succeeded but did not maintain the index. As a result, a row inserted (or whose indexed value changed) viaREPLACEwas not reflected in a subsequent index-backed ANN/KNN orMATCH ... AGAINSTquery until the next cron reindex.INSERTwas not affected.Root cause: the modern operator-based
REPLACEpath (DEDUP JOIN + MULTI_UPDATE, introduced by #24044) stripped irregular indexes viagetValidIndexesand relied on async maintenance. This PR restores synchronous maintenance for non-async ivfflat and fulltext indexes, leaving async ones to the cron exactly as the legacy insert/update paths do.How
tableDef.Indexes.SINK_SCAN) so auto-increment / generated columns are evaluated a single time and the same rows feed both the main conflict-resolution branch and the index-maintenance sub-plans.createQuery(the same sequencing the legacy insert path uses): they use positional column refs and hand-built nodes, so they must not go through the per-step optimize/remap pipeline. Only the newly appended steps are finalized viahandleHashMapMessages.org_pkis removed; a brand-new PK matches nothing and deletes nothing.POSTDMLnode per index deletes the stale inverted entries (by doc id = the incoming PK) and re-tokenizes the new rows.Regular tables and regular secondary indexes are unaffected.
Known limitation: for the rare case of a table with both an irregular index and a unique secondary index, a unique-key-only conflict (where the replaced row's PK differs from the incoming PK) is not yet covered for the irregular index; tracked as a follow-up.
Tests
test/distributed/cases/vector/vector_ivf_replace.sqlandtest/distributed/cases/fulltext/fulltext_replace.sqlcovering new-row REPLACE, existing-row REPLACE (stale value cleared) and multi-row REPLACE.TestCollectSyncIvfMultiIndexesandTestCollectSyncFulltextIndexes.go test ./pkg/sql/planpasses; existingvector_ivf_membership/fulltext/fulltext_membershipBVTs pass with no regression.🤖 Generated with Claude Code