Skip to content

[Bug]: INSERT IGNORE ... ON DUPLICATE KEY UPDATE persists CHECK-invalid rows #33523

Description

@Ariznawlll

Is there an existing issue for the same bug?

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

Related issues do not cover this surviving path: #26820 covered ordinary UPDATE / non-IGNORE ODKU CHECK enforcement, #25099 is the broad historical CHECK issue, and #28254 covered warnings for rows that were already skipped correctly. None describes this INSERT IGNORE ... ON DUPLICATE KEY UPDATE final-row violation.

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

Under statement IGNORE, a duplicate-key UPDATE that produces a CHECK-invalid final row emits warning 3819 but still persists the invalid value. The stored row therefore violates the table's enforced CHECK constraint.

This is not limited to affected-rows or warning formatting: a fresh connection reads the CHECK-invalid value after the statement commits.

Steps to Reproduce

CREATE TABLE ck(
  id INT PRIMARY KEY,
  v INT,
  CONSTRAINT ck_positive CHECK(v > 0)
);
INSERT INTO ck VALUES(1,1),(2,2);

INSERT IGNORE INTO ck VALUES(1,5),(2,-1),(3,3)
ON DUPLICATE KEY UPDATE v=VALUES(v);

SHOW WARNINGS;
SELECT * FROM ck ORDER BY id;

Actual Behavior

Both MatrixOne and MySQL produce CHECK warning 3819, but their persisted rows differ:

Engine Fresh-connection rows
MatrixOne (1,5),(2,-1),(3,3)
MySQL 8.0.46 (1,5),(2,2),(3,3)

MatrixOne reports success and stores (2,-1), despite ck_positive CHECK(v > 0) remaining defined and enforced for other write paths.

A same-key ordered-action discriminator shows that this is not merely input-row folding:

CREATE TABLE cks(
  id INT PRIMARY KEY,
  v INT,
  CONSTRAINT cks_positive CHECK(v > 0)
);
INSERT INTO cks VALUES(1,1);

INSERT IGNORE INTO cks VALUES(1,5),(1,-1),(2,2)
ON DUPLICATE KEY UPDATE v=VALUES(v);
SELECT * FROM cks ORDER BY id;
  • MatrixOne: (1,-1),(2,2); the later invalid action overwrites the valid intermediate value.
  • MySQL: (1,5),(2,2); the invalid action is skipped and the valid update survives.

Expected Behavior

The CHECK-invalid duplicate UPDATE action should be skipped under IGNORE, with warning 3819 retained. The prior valid value (2,2) must remain, while valid sibling actions commit. No committed row may violate its declared enforced CHECK constraint.

Stability and Controls

  • Reproduced in two independent MatrixOne databases and two independent MySQL databases.
  • Immediate readbacks used fresh connections before subsequent controls.
  • Plain non-IGNORE ODKU with the same invalid action returns 3819 and preserves the old row on both engines.
  • Pure INSERT IGNORE without ODKU correctly skips the CHECK-invalid row on both engines.
  • Fully valid same-key ODKU chains and valid sibling inserts succeed on both engines.
  • Post-probe SELECT 42 succeeds; there is no connection or availability failure.

Likely Mechanism from Read-only Source Inspection

  • The executable ODKU assignment list selects Node_UPDATE, rather than the pure-INSERT Node_IGNORE row-filter path: bind_insert.go.
  • ODKU CHECK validation calls appendCheckConstraintPlan(..., false), selecting an ASSERT rather than the cardinality-changing IGNORE filter: bind_insert.go, build_constraint_util.go.
  • Under statement IGNORE, _check_constraint_assert emits warning 3819 and returns false, but the compiled ASSERT path preserves the row instead of compacting the false bitmap: list_builtIn.go, filter.go.

The source path agrees with the observed warning-plus-invalid-write result; the final fix should be validated against both the minimal case and the same-key ordered-action case above.

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@1dfcb9cf2e10ac9676411658f3eb8bc7。确认最终 merge 与实际受测的 b5946447 Git tree 均为 5d96125429ffb9e3e21482d905ed5c19e48af836;多 CN Proxy BVT 日志 确认使用该 revision 的共享 mo-service,实际运行 insert_ignore_constraint_actions.sql 86/86,无跳过。x86 UT 和两项 BVT 已通过;Required 仍因独立的 JED Coverage setup 超时 #33533 为红。未在本轮重跑旧版本,不作生产验收结论。

    原场景回归:重复键更新得出的 CHECK 非法行发出 3819,拒绝动作不发布;同组后续合法动作基于上一版已接受值继续,SQL 校验最终存储值。另有 offered CHECK 被拒但合法兄弟通过的对照。交接建议:QA 复核原 issue 的单一重复输入和提交后的新连接读回。

  7. Ariznawlll commented on Dec 1, 2026

    @Ariznawlll
    CollaboratorAuthor

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

    • 运行时 git_version() 与精确源码 SHA 一致;binary SHA-256:a856cb87a5b5af72d1b4aa9536a13919e8b46c819adc5f25688d9742f98a0848。
    • 最小 CHECK 用例连续 3 轮通过:warning 3819 保留,新连接严格读到 (1,5),(2,2),(3,3),不再提交 (2,-1)。
    • 同键有序动作用例也通过:严格读到 (1,5),(2,2),非法后续动作被跳过,先前合法更新与合法兄弟 INSERT 均保留。
    • 非 IGNORE error 3819 且无副作用、纯 INSERT IGNORE、全合法同键链控制均通过;每轮 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