Skip to content

[Bug]: Regular secondary index can be invisible to another CN immediately after successful DDL #28639

Closed

Description

@gouhongshen

Is there an existing issue for the same bug?

  • I searched open and closed MatrixOne issues for the exact test, database/index names, error 1176, regular CREATE INDEX, and cross-CN catalog visibility. No issue covers this exact regular-secondary-index failure.

Branch Name

main

Commit ID

87ec737f6481d20c6b0559c96e1d992dc4804dbe

Other Environment Information

Actual Behavior

The regular secondary-index branch of TestIssue27487ConcurrentInsertIsIncludedInNewIndex completed its concurrent CREATE INDEX idx_k ON regular_docs(k) successfully on the DDL CN. The verifier CN immediately planned:

EXPLAIN SELECT COUNT(*)
FROM issue_27487_concurrent_index.regular_docs FORCE INDEX(idx_k)
WHERE k = 27487;

and failed with:

Error 1176 (42000): Key 'idx_k' doesn't exist in table 'regular_docs'

The job log shows the hidden secondary-index insert finishing at approximately 12:22:48.200Z, the constraint update/DDL commit at approximately 12:22:48.210Z, and the verifier failure at approximately 12:22:48.212Z. The failure is therefore post-DDL metadata visibility on another CN, before result validation.

The failing test source is byte-identical at the workflow base and PR head (sha256 dcd1465c702dfdd5311b89768e7370c1f38327b743feb2ff18016b3c6a753399), and the triggering PR does not modify regular-index creation or catalog/logtail visibility paths.

Expected Behavior

After a regular CREATE INDEX returns success, a new transaction on every CN should resolve the committed index definition immediately. Callers and tests should not require a sleep, manual synccommit, or same-CN routing.

Steps to Reproduce

1. Start the authenticated embedded MatrixOne fixture with at least two CNs.
2. Run `TestIssue27487ConcurrentInsertIsIncludedInNewIndex/regular_secondary_index` under the coverage configuration used by the linked job.
3. Let the test create/seed `regular_docs` on one CN, hold a concurrent writer transaction, and run `CREATE INDEX idx_k ON regular_docs(k)` on another CN.
4. After the writer commits and CREATE INDEX returns success, immediately execute the existing `EXPLAIN ... FORCE INDEX(idx_k)` verification through the other CN.
5. Observe intermittent Error 1176 because that CN has not resolved the committed index definition.

Additional information

Attribution evidence

  • pkg/tests/issues/issue_27487_test.go is unchanged between base 87ec737f6481d20c6b0559c96e1d992dc4804dbe and PR head 5d21e3d2ae521b5babf248a47a57fccf3bd80b46.
  • The failure occurs in the existing cross-CN verifier at issue_27487_test.go:101, reached from the regular-index case around lines 369/173.
  • The package did not hit its outer budget; this exact subtest failed in about 0.39 seconds.

Related but not duplicate

Acceptance criteria

  1. Once regular CREATE INDEX returns success, a new transaction on each CN immediately resolves the committed index definition.
  2. The existing concurrent regular-index commit/rollback cases pass repeatedly under coverage without sleeps, manual synccommit, or same-CN routing.
  3. Add directed evidence/test coverage around DDL commit TS, verifier snapshot/catalog watermark, table-definition version, and visible constraint/index definitions so the causal visibility boundary is deterministic.

Activity

  1. added
    kind/bug
    on Sep 10, 2026
  2. self-assigned this
    on Sep 10, 2026
  3. gouhongshen commented on Sep 10, 2026

    @gouhongshen
    ContributorAuthor

    Automated AI triage

    This issue requires human involvement and cannot currently be completed independently by the
    automated fix loop.

    Reason

    Human transaction/DDL owners must decide whether successful DDL overrides the configured cross-CN freshness trade-off and define its latency/error contract; then scope the catalog-barrier behavior.

    Evidence

    The repository documents that enable-sacrificing-freshness permits a CN not to see another CN's latest commit, and defaults it enabled. The reported verifier is a new transaction on a different CN immediately after DDL, precisely the unspecified boundary.

    Please use this analysis to provide the missing decision, environment, evidence, or ownership
    needed before the issue is returned to the AI candidate pool.

  4. added
    severity/s0
    ai-easy
    and removed on Sep 10, 2026
  5. gouhongshen commented on Sep 10, 2026

    @gouhongshen
    ContributorAuthor

    CI follow-up for PR #28272:

    • Workflow run 34474253139 was attempt 1 when the unrelated coverage failure was classified.
    • After the PR-local SCA defect was fixed and pushed, the one permitted gh run rerun 34474253139 --failed was requested.
    • GitHub created attempt 2, but branch concurrency cancelled the coverage rerun job 102880000571 after a newer PR head was pushed. No second rerun will be requested.
    • The original failure evidence remains valid: the regular-index test source was identical at the PR base/head, CREATE INDEX had returned success, and the verifier CN failed immediately with Error 1176.
  6. gouhongshen commented on Sep 10, 2026

    @gouhongshen
    ContributorAuthor

    Deferred: global DDL visibility needs a transaction/catalog owner decision

    Investigated at 7bc20830f018aaef36f61cda035186760e886254.

    Findings

    • The embedded two-CN fixture uses the normal CN transaction configuration. cnservice.Config.SetDefaultValue defaults enable-sacrificing-freshness to 1, and cnservice/server.go therefore builds each CN transaction client with WithEnableSacrificingFreshness().
    • In that mode txnClient.determineTxnSnapshot preserves the caller's minimum timestamp instead of advancing to the current/global timestamp. The verifier in issue_27487_test.go is a CN0 connection established before the CN1 DDL; it has no CN1 DDL commit timestamp to carry as its next-transaction minimum. A stale CN0 TableDef is therefore permitted by the configured contract.
    • FORCE INDEX validates the named index during planning in plan.recordIndexHints -> validateIndexHintNames; an old TableDef returns ER_KEY_DOES_NOT_EXIST before compile.LockMeta can acquire its metadata lock and trigger the existing definition-change retry.
    • This is not the fix(fulltext): validate stale cross-CN plans before execution #28289 FULLTEXT path. That fix can compile an unresolved placeholder, then validate/retry before execution. A generic regular-index binding error has no equivalent post-plan retry point.
    • The repository already treats cross-CN freshness as an explicit boundary. mo_ctl('cn', 'SYNCCOMMIT', '') is used by cross-CN tests that require it; CmdMethod_SyncCommit calls TxnClient.SyncLatestCommitTS on the addressed CN. [Bug]: New proxy-routed CN can miss a committed CREATE TABLE #27743 instead establishes a TN-ordered catalog barrier only for a fresh external special-user authentication path. Neither mechanism defines global immediate visibility for arbitrary already-open sessions.
    • A FORCE-INDEX-specific retry would merely mask this one early planner error while leaving SHOW/USE/IGNORE INDEX, prepared statements, other schema DDL, and ordinary catalog reads on the same stale-CN contract. It is not a complete fix for this issue. Adding SYNCCOMMIT, a sleep, or a retry to the regression would violate its acceptance criteria.

    Reproduction and test construction

    After building the required local CGo artifacts with make cgo, I ran the exact existing embedded multi-CN regression:

    .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=8m \
      -run '^TestIssue27487ConcurrentInsertIsIncludedInNewIndex$/regular_secondary_index$' \
      ./pkg/tests/issues
    # PASS: regular_secondary_index (0.10s), package 13.1s
    
    .agents/skills/mo-dev/scripts/mo-cgo-test -count=10 -timeout=8m \
      -run '^TestIssue27487ConcurrentInsertIsIncludedInNewIndex$/regular_secondary_index$' \
      ./pkg/tests/issues
    # PASS: package 13.4s
    

    The 11 local executions passed. That does not negate the CI failure: the current test controls DDL-vs-writer lock ordering, but does not deterministically hold CN0's catalog/logtail frontier behind the committed DDL timestamp. Its immediate verifier can either arrive before or after CN0 applies the logtail. A deterministic test requires an owner-approved common injection/observable fence at catalog application, not another timing loop.

    Required decision

    Please have the transaction/catalog owner define the DDL visibility contract:

    1. Does successful ordinary schema DDL guarantee visibility to every current CN and already-open session, or is cross-CN freshness intentionally opt-in?
    2. If a global DDL fence is required, what is its participant set, timeout/unavailable-CN behavior, join/leave rule, and latency budget?
    3. Which schema operations share that guarantee, and which common transaction/catalog publication boundary owns it?

    Implementing a commit-side global fence or changing transaction snapshot selection without those answers changes cluster-wide DDL latency and availability semantics. No safe focused implementation or executable proof can be produced before that decision.

  7. added
    severity/s0
    and removed
    severity/s0
    on Sep 10, 2026
  8. gouhongshen commented on Sep 10, 2026

    @gouhongshen
    ContributorAuthor

    PR #28641 is trying to fix this issue.

  9. gouhongshen commented on Sep 24, 2026

    @gouhongshen
    ContributorAuthor

    PR #28641 has merged and is awaiting manual validation. The issue remains open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions