Skip to content

[Bug]: Investigate remaining causes of secondary index inconsistency #32245

Open

Description

@iamlinjunhong

Is there an existing issue for the same bug?

  • I have checked open and closed issues.

This is an investigation tracker, not a claim that the historical #29235 race remains unfixed on main. Existing concrete reports are linked rather than duplicated: #25341, #25873, #28931 and #32056. No tracker for the remaining non-PK-covering old-row cohort was found.

Branch Name

main (investigation scope; the field origin/version is unresolved)

Commit ID

Code reviewed and locally built: 1d51125661c60ff5216c1216a897a3d312875336.
Comparison branch: 4.2-dev 58edabfe8f9f8a6c126e0634e7246c031a6f0ade.

Other Environment Information

The motivating observations came from a test environment. All SQL shown here is synthetic. Exact historical deployed versions and DDL records are unavailable; current code must not be used as proof of which code produced the historical state.

Actual Behavior

An investigation found historical base rows without matching hidden-index entries, including ordinary and unique indexes whose declared columns do not cover the full primary key. Some tables show an old cohort entirely absent from their indexes while subsequent rows are maintained. Later table rebuilds preserved that gap. The reported field sample did not show orphan, stale-key or duplicate entries. Inspection was partial: not all indexes received a key-level comparison.

Established boundaries

  1. Fixed historical mechanism: [Bug]: VARCHAR equality predicate returns zero rows with owner-bound PK and covering secondary index #25341 skipped maintenance for indexes whose declared columns cover the primary key. Current main and 4.2 getValidIndexes maintain regular indexes with TableExist=true. This does not explain the non-covering group without additional evidence.
  2. Propagation, not origin: SkipIndexesCopy suppresses copy-side DML maintenance for unaffected indexes; cloneUnaffectedIndexes copies the existing hidden data. On both exact local revisions, a deliberately removed entry in a disposable synthetic table remained missing after an unrelated-column COPY ALTER; changing an indexed column rebuilt that index and removed the injected gap. An ALTER-created table/index identity is therefore not evidence that the index was rebuilt from the base rows.
  3. Separate reproduced defect: [Bug]: COPY ALTER of a composite primary-key type leaves stale secondary-index references and misses rows #32056 covers composite-PK type changes cloning old secondary-index references. This investigation reproduced it on both exact revisions: two base rows and two index rows, but two missing current-PK references and two orphan old-PK references. New inserts use the new encoding. This differs from the field's reported missing-only pattern and is not assigned as its cause.
  4. Additional ALTER trigger: on both revisions, MODIFY id BIGINT, ADD extra INT for a single-column INT PK and UNIQUE(u) succeeds but clones INT index objects into a BIGINT origin-PK schema. Reading that unique index fails with object column type INT does not match destination type BIGINT. Reversing the clauses rebuilds correctly. This is a separate pkAffected overwrite trigger in the same invalidation/clone boundary; supporting details will be added to [Bug]: COPY ALTER of a composite primary-key type leaves stale secondary-index references and misses rows #32056.
  5. Historical candidate only: fix table clone visibility for repeated alter #24987 fixed repeated ALTER in one transaction omitting uncommitted index objects. Both current branches and the checked ce99d32 contain that fix. It resembles missing-all-old-rows, but requires proof that the earlier affected deployment lacked it and executed that sequence.
  6. main contains fix: serialize CREATE INDEX with concurrent DDL and DML #29235's CREATE INDEX synchronization. A separate branch tracker evaluates the remaining 4.2 gap; no latest-4.2 row-loss reproduction is claimed.

Expected Behavior

Identify the first operation that made a healthy base/index pair inconsistent, with a public-interface reproducer and exact version. Keep origin, later propagation, and unrelated confirmed defects separate.

Steps to Reproduce

The motivating missing-only historical cohort is not reproduced. #32056 supplies an independently reproducible stale-reference failure, not a reproduction of that field signature.

Synthetic propagation control (only in a disposable local database):

CREATE TABLE t(id INT PRIMARY KEY, k INT, n INT, KEY ix(k));
INSERT INTO t VALUES(1,10,0),(2,20,0);
-- Diagnostic setup only: remove the hidden ix entry for id=1.
-- This intentionally starts from an inconsistent index, so it proves propagation only.
ALTER TABLE t MODIFY n BIGINT;
-- Gap remains in the replacement hidden table.
ALTER TABLE t MODIFY k BIGINT;
-- ix is rebuilt from base rows; gap disappears.

Additional information

Investigation checklist:

Local controls passed on both exact revisions: ordinary DML, INSERT SELECT, supported ODKU, REPLACE, DELETE, rollback/duplicate failure, repeated unrelated COPY ALTER in a transaction, LOAD DATA INLINE, clone/data branch, clone failure rollback, and prepared DML after index creation/rebuild. Two-CN held-writer handoffs and cross-CN prepared INSERT also passed. These small controls are not a full concurrency/crash/large-load proof.

No root cause is assigned to the remaining missing-only cohort. Required next evidence is historical deployment/version and DDL/migration history, not another count-only scan.

Activity

  1. added
    severity/s0
    on Nov 5, 2026
  2. XuPeng-SH commented on Nov 6, 2026

    @XuPeng-SH
    Contributor

    已合并修复的范围补充:本调查总项继续保留研发,不因关联 PR 合入而转为整体 QA 验收。

    仍未完成的是历史部署 commit/image 与 DDL/事务时序、第一代不一致快照/源 clone,以及有证据支持的 metadata/stale-plan/restore/clone 分支调查。人为删除 hidden entry 后 COPY 保留缺口仅证明传播,不证明来源;旧行缺失与 stale/orphan 反例应继续区分。保持当前负责人,不改标签或关闭 issue;本条不新增自动 backport 要求,也不把两个子问题的转测当作总项完成。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triageseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions