Skip to content

fix: invalidate prepared special-index plans after index rebuild - #25669

Merged
XuPeng-SH merged 2 commits into
mainfrom
fix/25625-prepared-special-index-invalidation
Jul 13, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
fix/25625-prepared-special-index-invalidation

Conversation

@aptend

@aptend aptend commented Jul 13, 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:

Fixes #25625

What this PR does / why we need it:

Prepared statements previously tracked base-table schemas but omitted the hidden tables used by registered FULLTEXT and vector-index plugins. After DROP/CREATE INDEX, execution could therefore reuse a plan bound to deleted or replaced hidden tables.

This PR:

  • collects every registered index-plugin hidden table referenced by a TABLE_SCAN while ResetPreparePlan builds Prepare.Schemas;
  • resolves and records each hidden table database ID, table ID, name, and catalog version;
  • reuses the existing EXECUTE-time catalog invalidation and plan rebuild path;
  • adds a regression test for hidden-table schema collection.

Local FULLTEXT verification after DROP/CREATE INDEX: the pre-DDL prepared statement, rebuilt prepared execution, and fresh SQL all return the same row.

Validation:

  • go build ./pkg/sql/plan
  • go vet ./pkg/sql/plan
  • go test -count=1 -timeout 120s ./pkg/sql/plan
  • go test -count=1 -timeout 120s -run TestInitExecuteStmtParam ./pkg/frontend

@aptend
aptend requested review from XuPeng-SH and aunjgr as code owners July 13, 2026 09:43
@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 →

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

LGTM after reviewing this from the prepared-plan dependency, plugin-hidden-table, and unhappy-path angles.

  • correctness: the prepare-plan schema collection now records the hidden tables behind registered FULLTEXT/vector plugins, so DROP/CREATE INDEX and REINDEX can invalidate the prepared plan through the existing EXECUTE-time schema-version path
  • plugin wiring: the extra dependencies are resolved through ResolveIndexTableByRef from the owning base-table scan, which keeps the collected object/table/version metadata aligned with the same catalog path the runtime uses
  • unhappy path coverage: the new regression covers hidden-table schema collection directly, and the plan/frontend package tests exercise the existing rebuild path rather than introducing a new invalidation mechanism

I did not find a remaining correctness, leak, or hang issue in the latest diff, so approving.

@mergify mergify Bot added the queued label Jul 13, 2026
@mergify

mergify Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-13 11:21 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-13 11:24 UTC · at 5b35cfea5b2087566c41d3c2e5169935523087bc

This pull request spent 2 minutes 38 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]

Reason

Pull request #25669 has been merged manually at 58a1522

Hint

You were too fast!

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 58a1522 into main Jul 13, 2026
8 of 9 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/25625-prepared-special-index-invalidation branch July 13, 2026 11:23
@mergify mergify Bot added dequeued and removed queued labels Jul 13, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#25669)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25625

## What this PR does / why we need it:

Prepared statements previously tracked base-table schemas but omitted
the hidden tables used by registered FULLTEXT and vector-index plugins.
After DROP/CREATE INDEX, execution could therefore reuse a plan bound to
deleted or replaced hidden tables.

This PR:

- collects every registered index-plugin hidden table referenced by a
TABLE_SCAN while ResetPreparePlan builds Prepare.Schemas;
- resolves and records each hidden table database ID, table ID, name,
and catalog version;
- reuses the existing EXECUTE-time catalog invalidation and plan rebuild
path;
- adds a regression test for hidden-table schema collection.

Local FULLTEXT verification after DROP/CREATE INDEX: the pre-DDL
prepared statement, rebuilt prepared execution, and fresh SQL all return
the same row.

Validation:

- go build ./pkg/sql/plan
- go vet ./pkg/sql/plan
- go test -count=1 -timeout 120s ./pkg/sql/plan
- go test -count=1 -timeout 120s -run TestInitExecuteStmtParam
./pkg/frontend

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#25669)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25625

## What this PR does / why we need it:

Prepared statements previously tracked base-table schemas but omitted
the hidden tables used by registered FULLTEXT and vector-index plugins.
After DROP/CREATE INDEX, execution could therefore reuse a plan bound to
deleted or replaced hidden tables.

This PR:

- collects every registered index-plugin hidden table referenced by a
TABLE_SCAN while ResetPreparePlan builds Prepare.Schemas;
- resolves and records each hidden table database ID, table ID, name,
and catalog version;
- reuses the existing EXECUTE-time catalog invalidation and plan rebuild
path;
- adds a regression test for hidden-table schema collection.

Local FULLTEXT verification after DROP/CREATE INDEX: the pre-DDL
prepared statement, rebuilt prepared execution, and fresh SQL all return
the same row.

Validation:

- go build ./pkg/sql/plan
- go vet ./pkg/sql/plan
- go test -count=1 -timeout 120s ./pkg/sql/plan
- go test -count=1 -timeout 120s -run TestInitExecuteStmtParam
./pkg/frontend

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#25669)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25625

## What this PR does / why we need it:

Prepared statements previously tracked base-table schemas but omitted
the hidden tables used by registered FULLTEXT and vector-index plugins.
After DROP/CREATE INDEX, execution could therefore reuse a plan bound to
deleted or replaced hidden tables.

This PR:

- collects every registered index-plugin hidden table referenced by a
TABLE_SCAN while ResetPreparePlan builds Prepare.Schemas;
- resolves and records each hidden table database ID, table ID, name,
and catalog version;
- reuses the existing EXECUTE-time catalog invalidation and plan rebuild
path;
- adds a regression test for hidden-table schema collection.

Local FULLTEXT verification after DROP/CREATE INDEX: the pre-DDL
prepared statement, rebuilt prepared execution, and fresh SQL all return
the same row.

Validation:

- go build ./pkg/sql/plan
- go vet ./pkg/sql/plan
- go test -count=1 -timeout 120s ./pkg/sql/plan
- go test -count=1 -timeout 120s -run TestInitExecuteStmtParam
./pkg/frontend

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
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 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Prepared FULLTEXT and vector statements keep stale hidden-index plans after index DDL

3 participants