Skip to content

fix(fulltext2): implement ALTER-column plan hooks for INCLUDE columns (#27964) - #28009

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
cpegeric:bug_27964
Sep 2, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
cpegeric:bug_27964

Conversation

@cpegeric

@cpegeric cpegeric commented Sep 2, 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 #27964

What this PR does / why we need it:

Renaming or dropping a column referenced in a fulltext2 INCLUDE clause left stale metadata and broke incremental (ISCP CDC) indexing: SHOW CREATE TABLE kept showing the old/dropped column, and post-rename inserts were never indexed (MATCH returned only the pre-rename rows).

Root cause: the SQL ALTER path (pkg/sql/plan/vector_index_alter.go) delegates include-column maintenance to optional per-plugin hooks (AlterColumnHooks / RenameColumnRebuildHook). Every vector index (ivfflat/ivfpq/cagra) implements them, but fulltext2 did not, so its INCLUDE metadata was never rewritten and no rebuild was triggered.

Fix: add pkg/fulltext2/plugin/plan/alter.go, mirroring ivfflat's alter hooks, so fulltext2's plan.Hooks satisfies the interfaces the SQL layer type-asserts:

  • HandleAlterRenameColumn -> RenameIncludedColumnsForAlgo (rewrites the INCLUDE name in both IndexDef.IncludedColumns and the IndexAlgoParams JSON via the emitted mo_indexes UPDATE), with catalog.MoIndexFullText2Algo.
  • RenameColumnRequiresIndexRebuild -> IncludedColumnAffected: renaming an INCLUDE column triggers a COPY rebuild so incremental indexing resumes.
  • HandleAlterDropColumn / UpdateColumnRequiresIndexRewrite -> IncludedColumnAffected: dropping an INCLUDE column drops the index (ivfflat parity); MODIFY rewrites.

No SQL-layer or per-algo switch changes — pure plugin-hook wiring (G-IDXPLUGIN clean). Classic fulltext has no INCLUDE support, so it is unaffected.

Tests:

  • Unit: pkg/fulltext2/plugin/plan/alter_test.go (mirrors ivfflat) covers all four hooks + a compile-time interface assertion.
  • BVT: test/distributed/cases/pessimistic_transaction/fulltext2/ fulltext2_include_rename.{sql,result} — full [Bug]: Renaming a Fulltext2 INCLUDE column leaves stale metadata and stops incremental indexing #27964 repro using the cdc_tail @wait_expect poll (deterministic): rename INCLUDE col -> SHOW CREATE shows the new name and MATCH returns the post-rename incremental row; covering query serves the INCLUDE column under its new name; drop INCLUDE col drops the index; renaming a non-INCLUDE column leaves the index intact. Validated -m run -g -n: 31/31, 100%.

…matrixorigin#27964)

Renaming or dropping a column referenced in a fulltext2 INCLUDE clause left
stale metadata and broke incremental (ISCP CDC) indexing: SHOW CREATE TABLE
kept showing the old/dropped column, and post-rename inserts were never indexed
(MATCH returned only the pre-rename rows).

Root cause: the SQL ALTER path (pkg/sql/plan/vector_index_alter.go) delegates
include-column maintenance to optional per-plugin hooks (AlterColumnHooks /
RenameColumnRebuildHook). Every vector index (ivfflat/ivfpq/cagra) implements
them, but fulltext2 did not, so its INCLUDE metadata was never rewritten and no
rebuild was triggered.

Fix: add pkg/fulltext2/plugin/plan/alter.go, mirroring ivfflat's alter hooks,
so fulltext2's plan.Hooks satisfies the interfaces the SQL layer type-asserts:
- HandleAlterRenameColumn -> RenameIncludedColumnsForAlgo (rewrites the INCLUDE
  name in both IndexDef.IncludedColumns and the IndexAlgoParams JSON via the
  emitted mo_indexes UPDATE), with catalog.MoIndexFullText2Algo.
- RenameColumnRequiresIndexRebuild -> IncludedColumnAffected: renaming an
  INCLUDE column triggers a COPY rebuild so incremental indexing resumes.
- HandleAlterDropColumn / UpdateColumnRequiresIndexRewrite -> IncludedColumnAffected:
  dropping an INCLUDE column drops the index (ivfflat parity); MODIFY rewrites.

No SQL-layer or per-algo switch changes — pure plugin-hook wiring (G-IDXPLUGIN
clean). Classic fulltext has no INCLUDE support, so it is unaffected.

Tests:
- Unit: pkg/fulltext2/plugin/plan/alter_test.go (mirrors ivfflat) covers all four
  hooks + a compile-time interface assertion.
- BVT: test/distributed/cases/pessimistic_transaction/fulltext2/
  fulltext2_include_rename.{sql,result} — full matrixorigin#27964 repro using the cdc_tail
  @wait_expect poll (deterministic): rename INCLUDE col -> SHOW CREATE shows the
  new name and MATCH returns the post-rename incremental row; covering query
  serves the INCLUDE column under its new name; drop INCLUDE col drops the index;
  renaming a non-INCLUDE column leaves the index intact. Validated -m run -g -n:
  31/31, 100%.

Co-Authored-By: Claude Opus 4.8 (1M context) <[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 →

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Sep 2, 2026

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

Deep review completed on exact head 504aee8.

The plugin-hook fix closes the actual failure chain: Fulltext2 INCLUDE metadata is rewritten in both in-memory IndexDefs and persisted algo_params, the rename is routed through COPY, the affected logical index is rebuilt instead of shallow-cloned, and the async CDC writer is re-registered against the renamed source schema.

Counterexamples checked: both physical Fulltext2 definitions, multiple logical indexes, legacy algo_params fallback, quoted/special identifiers, non-INCLUDE rename, INCLUDE drop, malformed metadata error propagation, ordinary UPDATE/ODKU interaction, and failure/rollback boundaries. Always-async Fulltext2 remains excluded from synchronous DML maintenance, so the new update hook does not add foreground index work.

The COPY/rebuild cost can be substantial for a large table, but it is bounded to this rare schema mutation and the affected indexes; under the current lifecycle it is the correctness boundary that prevents a stale or unregistered CDC writer. The end-to-end BVT proves metadata, rebuild readiness, post-rename incremental search, and covering output. Exact-head Linux UT, SCA, coverage, and BVT are green; diff check is clean. Local package UT was unavailable only because this isolated macOS worktree lacks a matching cgo/libmo.dylib.

@mergify mergify Bot added the queued label Sep 2, 2026
@mergify

mergify Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-02 11:53 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-09-02 12:46 UTC · at e0a87386511de6c3a1379a5024b269b84b5ca1c8 · squash

This pull request spent 52 minutes 36 seconds in the queue, including 48 minutes 21 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

@mergify
mergify Bot merged commit e0a8738 into matrixorigin:main Sep 2, 2026
26 of 27 checks passed
@mergify mergify Bot removed the queued label Sep 2, 2026
mergify Bot pushed a commit that referenced this pull request Sep 2, 2026
### Root cause

`TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` runs a full-cluster restore against the base cluster returned by `embed.RunBaseClusterTests`. A full-cluster restore replaces cluster-wide catalog tables, including `mo_catalog.mo_role_privs`. `SharedTestCluster.Run` keeps that cluster alive for subsequent issue tests and does not rebuild it after the callback changes catalog state or times out.

In CI run 33618283377, the restore path replaced `mo_catalog.mo_role_privs`; subsequent unrelated tests using the shared `sys:dump` / `moadmin` session failed with Error 20101 (`do not have privilege to execute the statement`) during normal DDL and account setup or cleanup. The failure therefore came from sharing a cluster across a destructive full-cluster restore, not from the unrelated Data Branch changes.

### Changes

- Move only `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` into the existing `pkg/tests/issues/isolated` package.
- Start a dedicated two-CN test cluster with the authentication, lock-service, and Iceberg settings required by the original test, wait for system bootstrap, and close the cluster with test cleanup.
- Preserve the original full SQL scenario and assertions for account ID remapping, publication metadata rebinding, subscription privilege object rebinding, and reader access.
- Keep the account-scoped #26640 restore and PITR tests on the shared base-cluster helper because they do not perform a full-cluster catalog replacement.

No production code or SQL behavior is changed.

### Issue-to-test proof

The moved regression test creates publisher and subscriber accounts, a publication and subscription, roles and grants, takes a cluster snapshot, drops both accounts, restores the full cluster, and verifies:

- restored account IDs differ from the source IDs;
- publication account and database IDs point to the restored objects;
- the subscription role privilege object ID points to the restored subscription database;
- the restored subscription reader can query the expected row.

The test now owns its cluster lifecycle in the isolated package, which has no shared base cluster. This prevents a failed or catalog-mutating full-cluster restore from affecting unrelated issue tests while retaining direct executable coverage of the original reproduction.

BVT is not appropriate for this change: no production SQL contract changed, and the behavior under test is test-cluster ownership and lifecycle isolation.

### Tests run

- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed on the final head, 26.185s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -race -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed, 112.612s.
- Full normal runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 85.837s and 261.079s respectively.
- Full race runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 512.671s and 317.342s respectively.
- `go vet ./pkg/tests/issues ./pkg/tests/issues/isolated` with the repository CGo include and linker flags — passed.
- `git diff --check origin/main...HEAD` — passed.

The full package runs were completed before the final rebase onto the latest `origin/main`; the rebase added only upstream commit #28009, and the focused normal and race tests were rerun on the final head.

### Residual risks

- The isolated test starts one additional two-CN cluster. Its final focused normal run took 26.185s; this is the necessary cost of preventing shared-cluster catalog contamination.
- Full-cluster restore remains a long-running integration path with the original bounded 300-second test context and can still expose genuine restore failures.
- Because this is a test-fixture isolation change, any remaining CI privilege cascade would indicate another test mutating the shared base cluster.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…matrixorigin#27964) (matrixorigin#28009)

Renaming or dropping a column referenced in a fulltext2 INCLUDE clause left stale metadata and broke incremental (ISCP CDC) indexing: SHOW CREATE TABLE kept showing the old/dropped column, and post-rename inserts were never indexed (MATCH returned only the pre-rename rows).

Root cause: the SQL ALTER path (pkg/sql/plan/vector_index_alter.go) delegates include-column maintenance to optional per-plugin hooks (AlterColumnHooks / RenameColumnRebuildHook). Every vector index (ivfflat/ivfpq/cagra) implements them, but fulltext2 did not, so its INCLUDE metadata was never rewritten and no rebuild was triggered.

Fix: add pkg/fulltext2/plugin/plan/alter.go, mirroring ivfflat's alter hooks, so fulltext2's plan.Hooks satisfies the interfaces the SQL layer type-asserts:
- HandleAlterRenameColumn -> RenameIncludedColumnsForAlgo (rewrites the INCLUDE name in both IndexDef.IncludedColumns and the IndexAlgoParams JSON via the emitted mo_indexes UPDATE), with catalog.MoIndexFullText2Algo.
- RenameColumnRequiresIndexRebuild -> IncludedColumnAffected: renaming an INCLUDE column triggers a COPY rebuild so incremental indexing resumes.
- HandleAlterDropColumn / UpdateColumnRequiresIndexRewrite -> IncludedColumnAffected: dropping an INCLUDE column drops the index (ivfflat parity); MODIFY rewrites.

No SQL-layer or per-algo switch changes — pure plugin-hook wiring (G-IDXPLUGIN clean). Classic fulltext has no INCLUDE support, so it is unaffected.

Tests:
- Unit: pkg/fulltext2/plugin/plan/alter_test.go (mirrors ivfflat) covers all four hooks + a compile-time interface assertion.
- BVT: test/distributed/cases/pessimistic_transaction/fulltext2/ fulltext2_include_rename.{sql,result} — full matrixorigin#27964 repro using the cdc_tail @wait_expect poll (deterministic): rename INCLUDE col -> SHOW CREATE shows the new name and MATCH returns the post-rename incremental row; covering query serves the INCLUDE column under its new name; drop INCLUDE col drops the index; renaming a non-INCLUDE column leaves the index intact. Validated -m run -g -n: 31/31, 100%.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8019)

### Root cause

`TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` runs a full-cluster restore against the base cluster returned by `embed.RunBaseClusterTests`. A full-cluster restore replaces cluster-wide catalog tables, including `mo_catalog.mo_role_privs`. `SharedTestCluster.Run` keeps that cluster alive for subsequent issue tests and does not rebuild it after the callback changes catalog state or times out.

In CI run 33618283377, the restore path replaced `mo_catalog.mo_role_privs`; subsequent unrelated tests using the shared `sys:dump` / `moadmin` session failed with Error 20101 (`do not have privilege to execute the statement`) during normal DDL and account setup or cleanup. The failure therefore came from sharing a cluster across a destructive full-cluster restore, not from the unrelated Data Branch changes.

### Changes

- Move only `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` into the existing `pkg/tests/issues/isolated` package.
- Start a dedicated two-CN test cluster with the authentication, lock-service, and Iceberg settings required by the original test, wait for system bootstrap, and close the cluster with test cleanup.
- Preserve the original full SQL scenario and assertions for account ID remapping, publication metadata rebinding, subscription privilege object rebinding, and reader access.
- Keep the account-scoped matrixorigin#26640 restore and PITR tests on the shared base-cluster helper because they do not perform a full-cluster catalog replacement.

No production code or SQL behavior is changed.

### Issue-to-test proof

The moved regression test creates publisher and subscriber accounts, a publication and subscription, roles and grants, takes a cluster snapshot, drops both accounts, restores the full cluster, and verifies:

- restored account IDs differ from the source IDs;
- publication account and database IDs point to the restored objects;
- the subscription role privilege object ID points to the restored subscription database;
- the restored subscription reader can query the expected row.

The test now owns its cluster lifecycle in the isolated package, which has no shared base cluster. This prevents a failed or catalog-mutating full-cluster restore from affecting unrelated issue tests while retaining direct executable coverage of the original reproduction.

BVT is not appropriate for this change: no production SQL contract changed, and the behavior under test is test-cluster ownership and lifecycle isolation.

### Tests run

- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed on the final head, 26.185s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -race -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed, 112.612s.
- Full normal runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 85.837s and 261.079s respectively.
- Full race runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 512.671s and 317.342s respectively.
- `go vet ./pkg/tests/issues ./pkg/tests/issues/isolated` with the repository CGo include and linker flags — passed.
- `git diff --check origin/main...HEAD` — passed.

The full package runs were completed before the final rebase onto the latest `origin/main`; the rebase added only upstream commit matrixorigin#28009, and the focused normal and race tests were rerun on the final head.

### Residual risks

- The isolated test starts one additional two-CN cluster. Its final focused normal run took 26.185s; this is the necessary cost of preventing shared-cluster catalog contamination.
- Full-cluster restore remains a long-running integration path with the original bounded 300-second test context and can still expose genuine restore failures.
- Because this is a test-fixture isolation change, any remaining CI privilege cascade would indicate another test mutating the shared base cluster.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…matrixorigin#27964) (matrixorigin#28009)

Renaming or dropping a column referenced in a fulltext2 INCLUDE clause left stale metadata and broke incremental (ISCP CDC) indexing: SHOW CREATE TABLE kept showing the old/dropped column, and post-rename inserts were never indexed (MATCH returned only the pre-rename rows).

Root cause: the SQL ALTER path (pkg/sql/plan/vector_index_alter.go) delegates include-column maintenance to optional per-plugin hooks (AlterColumnHooks / RenameColumnRebuildHook). Every vector index (ivfflat/ivfpq/cagra) implements them, but fulltext2 did not, so its INCLUDE metadata was never rewritten and no rebuild was triggered.

Fix: add pkg/fulltext2/plugin/plan/alter.go, mirroring ivfflat's alter hooks, so fulltext2's plan.Hooks satisfies the interfaces the SQL layer type-asserts:
- HandleAlterRenameColumn -> RenameIncludedColumnsForAlgo (rewrites the INCLUDE name in both IndexDef.IncludedColumns and the IndexAlgoParams JSON via the emitted mo_indexes UPDATE), with catalog.MoIndexFullText2Algo.
- RenameColumnRequiresIndexRebuild -> IncludedColumnAffected: renaming an INCLUDE column triggers a COPY rebuild so incremental indexing resumes.
- HandleAlterDropColumn / UpdateColumnRequiresIndexRewrite -> IncludedColumnAffected: dropping an INCLUDE column drops the index (ivfflat parity); MODIFY rewrites.

No SQL-layer or per-algo switch changes — pure plugin-hook wiring (G-IDXPLUGIN clean). Classic fulltext has no INCLUDE support, so it is unaffected.

Tests:
- Unit: pkg/fulltext2/plugin/plan/alter_test.go (mirrors ivfflat) covers all four hooks + a compile-time interface assertion.
- BVT: test/distributed/cases/pessimistic_transaction/fulltext2/ fulltext2_include_rename.{sql,result} — full matrixorigin#27964 repro using the cdc_tail @wait_expect poll (deterministic): rename INCLUDE col -> SHOW CREATE shows the new name and MATCH returns the post-rename incremental row; covering query serves the INCLUDE column under its new name; drop INCLUDE col drops the index; renaming a non-INCLUDE column leaves the index intact. Validated -m run -g -n: 31/31, 100%.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8019)

### Root cause

`TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` runs a full-cluster restore against the base cluster returned by `embed.RunBaseClusterTests`. A full-cluster restore replaces cluster-wide catalog tables, including `mo_catalog.mo_role_privs`. `SharedTestCluster.Run` keeps that cluster alive for subsequent issue tests and does not rebuild it after the callback changes catalog state or times out.

In CI run 33618283377, the restore path replaced `mo_catalog.mo_role_privs`; subsequent unrelated tests using the shared `sys:dump` / `moadmin` session failed with Error 20101 (`do not have privilege to execute the statement`) during normal DDL and account setup or cleanup. The failure therefore came from sharing a cluster across a destructive full-cluster restore, not from the unrelated Data Branch changes.

### Changes

- Move only `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` into the existing `pkg/tests/issues/isolated` package.
- Start a dedicated two-CN test cluster with the authentication, lock-service, and Iceberg settings required by the original test, wait for system bootstrap, and close the cluster with test cleanup.
- Preserve the original full SQL scenario and assertions for account ID remapping, publication metadata rebinding, subscription privilege object rebinding, and reader access.
- Keep the account-scoped matrixorigin#26640 restore and PITR tests on the shared base-cluster helper because they do not perform a full-cluster catalog replacement.

No production code or SQL behavior is changed.

### Issue-to-test proof

The moved regression test creates publisher and subscriber accounts, a publication and subscription, roles and grants, takes a cluster snapshot, drops both accounts, restores the full cluster, and verifies:

- restored account IDs differ from the source IDs;
- publication account and database IDs point to the restored objects;
- the subscription role privilege object ID points to the restored subscription database;
- the restored subscription reader can query the expected row.

The test now owns its cluster lifecycle in the isolated package, which has no shared base cluster. This prevents a failed or catalog-mutating full-cluster restore from affecting unrelated issue tests while retaining direct executable coverage of the original reproduction.

BVT is not appropriate for this change: no production SQL contract changed, and the behavior under test is test-cluster ownership and lifecycle isolation.

### Tests run

- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed on the final head, 26.185s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -race -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed, 112.612s.
- Full normal runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 85.837s and 261.079s respectively.
- Full race runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 512.671s and 317.342s respectively.
- `go vet ./pkg/tests/issues ./pkg/tests/issues/isolated` with the repository CGo include and linker flags — passed.
- `git diff --check origin/main...HEAD` — passed.

The full package runs were completed before the final rebase onto the latest `origin/main`; the rebase added only upstream commit matrixorigin#28009, and the focused normal and race tests were rerun on the final head.

### Residual risks

- The isolated test starts one additional two-CN cluster. Its final focused normal run took 26.185s; this is the necessary cost of preventing shared-cluster catalog contamination.
- Full-cluster restore remains a long-running integration path with the original bounded 300-second test context and can still expose genuine restore failures.
- Because this is a test-fixture isolation change, any remaining CI privilege cascade would indicate another test mutating the shared base cluster.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…matrixorigin#27964) (matrixorigin#28009)

Renaming or dropping a column referenced in a fulltext2 INCLUDE clause left stale metadata and broke incremental (ISCP CDC) indexing: SHOW CREATE TABLE kept showing the old/dropped column, and post-rename inserts were never indexed (MATCH returned only the pre-rename rows).

Root cause: the SQL ALTER path (pkg/sql/plan/vector_index_alter.go) delegates include-column maintenance to optional per-plugin hooks (AlterColumnHooks / RenameColumnRebuildHook). Every vector index (ivfflat/ivfpq/cagra) implements them, but fulltext2 did not, so its INCLUDE metadata was never rewritten and no rebuild was triggered.

Fix: add pkg/fulltext2/plugin/plan/alter.go, mirroring ivfflat's alter hooks, so fulltext2's plan.Hooks satisfies the interfaces the SQL layer type-asserts:
- HandleAlterRenameColumn -> RenameIncludedColumnsForAlgo (rewrites the INCLUDE name in both IndexDef.IncludedColumns and the IndexAlgoParams JSON via the emitted mo_indexes UPDATE), with catalog.MoIndexFullText2Algo.
- RenameColumnRequiresIndexRebuild -> IncludedColumnAffected: renaming an INCLUDE column triggers a COPY rebuild so incremental indexing resumes.
- HandleAlterDropColumn / UpdateColumnRequiresIndexRewrite -> IncludedColumnAffected: dropping an INCLUDE column drops the index (ivfflat parity); MODIFY rewrites.

No SQL-layer or per-algo switch changes — pure plugin-hook wiring (G-IDXPLUGIN clean). Classic fulltext has no INCLUDE support, so it is unaffected.

Tests:
- Unit: pkg/fulltext2/plugin/plan/alter_test.go (mirrors ivfflat) covers all four hooks + a compile-time interface assertion.
- BVT: test/distributed/cases/pessimistic_transaction/fulltext2/ fulltext2_include_rename.{sql,result} — full matrixorigin#27964 repro using the cdc_tail @wait_expect poll (deterministic): rename INCLUDE col -> SHOW CREATE shows the new name and MATCH returns the post-rename incremental row; covering query serves the INCLUDE column under its new name; drop INCLUDE col drops the index; renaming a non-INCLUDE column leaves the index intact. Validated -m run -g -n: 31/31, 100%.

Approved by: @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8019)

### Root cause

`TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` runs a full-cluster restore against the base cluster returned by `embed.RunBaseClusterTests`. A full-cluster restore replaces cluster-wide catalog tables, including `mo_catalog.mo_role_privs`. `SharedTestCluster.Run` keeps that cluster alive for subsequent issue tests and does not rebuild it after the callback changes catalog state or times out.

In CI run 33618283377, the restore path replaced `mo_catalog.mo_role_privs`; subsequent unrelated tests using the shared `sys:dump` / `moadmin` session failed with Error 20101 (`do not have privilege to execute the statement`) during normal DDL and account setup or cleanup. The failure therefore came from sharing a cluster across a destructive full-cluster restore, not from the unrelated Data Branch changes.

### Changes

- Move only `TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges` into the existing `pkg/tests/issues/isolated` package.
- Start a dedicated two-CN test cluster with the authentication, lock-service, and Iceberg settings required by the original test, wait for system bootstrap, and close the cluster with test cleanup.
- Preserve the original full SQL scenario and assertions for account ID remapping, publication metadata rebinding, subscription privilege object rebinding, and reader access.
- Keep the account-scoped matrixorigin#26640 restore and PITR tests on the shared base-cluster helper because they do not perform a full-cluster catalog replacement.

No production code or SQL behavior is changed.

### Issue-to-test proof

The moved regression test creates publisher and subscriber accounts, a publication and subscription, roles and grants, takes a cluster snapshot, drops both accounts, restores the full cluster, and verifies:

- restored account IDs differ from the source IDs;
- publication account and database IDs point to the restored objects;
- the subscription role privilege object ID points to the restored subscription database;
- the restored subscription reader can query the expected row.

The test now owns its cluster lifecycle in the isolated package, which has no shared base cluster. This prevents a failed or catalog-mutating full-cluster restore from affecting unrelated issue tests while retaining direct executable coverage of the original reproduction.

BVT is not appropriate for this change: no production SQL contract changed, and the behavior under test is test-cluster ownership and lifecycle isolation.

### Tests run

- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed on the final head, 26.185s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues/isolated -race -short -run '^TestIssue26640ClusterRestoreRebindsSubscriptionPrivileges$' -count=1 -timeout=15m` — passed, 112.612s.
- Full normal runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 85.837s and 261.079s respectively.
- Full race runs for `pkg/tests/issues` and `pkg/tests/issues/isolated` — passed, 512.671s and 317.342s respectively.
- `go vet ./pkg/tests/issues ./pkg/tests/issues/isolated` with the repository CGo include and linker flags — passed.
- `git diff --check origin/main...HEAD` — passed.

The full package runs were completed before the final rebase onto the latest `origin/main`; the rebase added only upstream commit matrixorigin#28009, and the focused normal and race tests were rerun on the final head.

### Residual risks

- The isolated test starts one additional two-CN cluster. Its final focused normal run took 26.185s; this is the necessary cost of preventing shared-cluster catalog contamination.
- Full-cluster restore remains a long-running integration path with the original bounded 300-second test context and can still expose genuine restore failures.
- Because this is a test-fixture isolation change, any remaining CI privilege cascade would indicate another test mutating the shared base cluster.

Approved by: @XuPeng-SH

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

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants