Skip to content

[Compatibility]: INSERT IGNORE skips FK orphan rows without warning 1452 #33521

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues, including closed issues.

This is an FK-specific residual related to closed #28254. That issue and its fix explicitly cover PK/UK/CHECK warnings for rows already skipped correctly; they do not cover the FK-only case below. #30715 concerns LOAD DATA IGNORE, whose warning-producing path is different. Open #33478 concerns UPDATE/DELETE IGNORE statement failure and sibling loss, not a successful plain INSERT with a missing diagnostic.

Branch Name

main

Commit ID

98b2097

Other Environment Information

  • Test date: 2026-11-30
  • Deployment: local standalone mo-service, 1 CN / 1 TN / 1 LogService, MySQL text protocol
  • Runtime identity checked with git_version()='98b20975' and SELECT 42
  • Comparator: MySQL 8.0.46, InnoDB

Description

Plain INSERT IGNORE correctly skips a child row whose foreign key references no parent, but MatrixOne leaves the warning area empty. MySQL exposes warning 1452 for the skipped orphan row.

The final stored rows are correct on both engines. This issue is limited to diagnostic compatibility, not persisted-data integrity.

Steps to Reproduce

This discriminator deliberately includes no duplicate-key input, so duplicate arbitration cannot hide or replace the FK warning:

CREATE TABLE p(id INT PRIMARY KEY);
INSERT INTO p VALUES(1);

CREATE TABLE c(
  id INT PRIMARY KEY,
  pid INT NOT NULL,
  CONSTRAINT fk_c_pid FOREIGN KEY(pid) REFERENCES p(id)
);

INSERT IGNORE INTO c VALUES(1,999),(2,1);
SHOW WARNINGS;
SELECT * FROM c ORDER BY id;

Actual Behavior

Observable MatrixOne MySQL 8.0.46
Statement result Success, 1 affected row Success, 1 affected row
SHOW WARNINGS Empty Warning 1452 for (1,999)
Fresh-connection rows (2,1) (2,1)

An orphan-only statement likewise affects zero rows on both engines, but only MySQL exposes warning 1452. In a mixed duplicate/orphan/valid batch, both engines retain the same valid rows; MySQL reports warnings 1062 and 1452, whereas MatrixOne reports only 1062.

Expected Behavior

When INSERT IGNORE skips a row because of an FK violation, SHOW WARNINGS should expose the corresponding warning 1452 (and the statement warning count should include it), while continuing to skip only the offending row.

Stability and Controls

  • Reproduced in two independent MatrixOne databases and two independent MySQL databases.
  • Covered orphan-only, orphan+valid, duplicate+orphan+valid, non-IGNORE, and fully valid controls.
  • Non-IGNORE orphan input returns error 1452 and stores no rows on both engines.
  • Fully valid INSERT IGNORE stores both rows with no warnings on both engines.
  • Every final readback used a fresh connection, and post-probe SELECT 42 succeeded.

Likely Mechanism from Read-only Source Inspection

Plain INSERT IGNORE reaches buildInsertIgnoreFkFilter: bind_insert.go.

Only the LOAD path (loadWarnings=true) wraps the FK predicate in _load_fk_ignore_check; ordinary INSERT IGNORE installs the raw FK-OK predicates as a FILTER. Rows are therefore removed correctly, but no warning-producing function is called: bind_insert.go.

A regression should include the no-duplicate discriminator above so that the FK diagnostic is tested independently of duplicate-key warnings.

Activity

  1. added
    kind/bug
    on Nov 30, 2026
  2. self-assigned this
    on Nov 30, 2026
  3. added theissue type on Nov 30, 2026
  4. added this to the MO-202611 milestone on Nov 30, 2026
  5. added a commit that references this issue on Nov 30, 2026
    1dfcb9c
  6. XuPeng-SH commented on Nov 30, 2026

    @XuPeng-SH
    Contributor

    转测前实测:从 #33528 最终 main@1dfcb9cf2e10ac9676411658f3eb8bc7ba155e5b 本地构建(Go 1.27.1 / Linux amd64),经真实 MySQL TCP 连接隔离单 CN,git_version() 返回完整 SHA。两个新库共 33/33 检查通过,子表均无自增列,原始 INSERT IGNORE INTO c VALUES(1,999),(2,1) 均只留 (2,1),SHOW WARNINGS 各有且仅有一个 1452。孤儿单行也返回 1452 warning;无 IGNORE 时 1452 error 且严格回滚整批;全合法批次无 warning 且两个合法行均入库。服务正常退出。

    本轮未在旧版重跑,旧版告警为空来自原 issue;未另外检查混合 duplicate+orphan 的警告计数、生产/多 CN 配置或二进制协议。QA 可按原用例复核警告数量和新连接回读。

  7. Ariznawlll commented on Dec 1, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在当前官方 main ba6081a1eaf7210acefd7181da5bfc07db10e8bc 完成原场景验收并关闭。

    • 运行时 git_version() 与精确源码 SHA 一致;binary SHA-256:a856cb87a5b5af72d1b4aa9536a13919e8b46c819adc5f25688d9742f98a0848。
    • 无 duplicate 判别用例连续 3 轮通过:INSERT IGNORE 成功且仅影响 1 行,SHOW WARNINGS 返回 warning 1452,新连接严格读到 (2,1)。
    • 同时通过 orphan-only、duplicate+orphan+valid 的 1062/1452 双 warning、非 IGNORE error 1452 且无副作用、全合法无 warning 控制;每轮 SELECT 42 及新连接健康检查通过。
    • 三项 Issue 合计原始场景及控制 9/9 PASS,验收开末官方 main SHA 未变化。
    • 独立 MOTR 回归已提交为 matrixorigin/motr#397,head dcb9259f9e7b8d0fe482c784a07fb524a9a0c540,本地 offline 967/967 PASS;未叠加旧 PR374/353。新 PR 的远端检查刚启动,不提前冒称全绿。

    证据:qa-33521-constraints/main-ba608/。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions