Repository navigation
Description
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
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'andSELECT 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 IGNOREwithout 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 42succeeds; 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-INSERTNode_IGNORErow-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_assertemits 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
fix(sql): preserve accepted INSERT IGNORE rows across constraint fail…
XuPeng-SH commentedon Nov 30, 2026
转测前验证:#33528 已合入
main@1dfcb9cf2e10ac9676411658f3eb8bc7。确认最终 merge 与实际受测的b5946447Git tree 均为5d96125429ffb9e3e21482d905ed5c19e48af836;多 CN Proxy BVT 日志 确认使用该 revision 的共享 mo-service,实际运行insert_ignore_constraint_actions.sql86/86,无跳过。x86 UT 和两项 BVT 已通过;Required 仍因独立的 JED Coverage setup 超时 #33533 为红。未在本轮重跑旧版本,不作生产验收结论。原场景回归:重复键更新得出的 CHECK 非法行发出 3819,拒绝动作不发布;同组后续合法动作基于上一版已接受值继续,SQL 校验最终存储值。另有 offered CHECK 被拒但合法兄弟通过的对照。交接建议:QA 复核原 issue 的单一重复输入和提交后的新连接读回。
Ariznawlll commentedon Dec 1, 2026
已在当前官方 main
ba6081a1eaf7210acefd7181da5bfc07db10e8bc完成原场景验收并关闭。git_version()与精确源码 SHA 一致;binary SHA-256:a856cb87a5b5af72d1b4aa9536a13919e8b46c819adc5f25688d9742f98a0848。(1,5),(2,2),(3,3),不再提交(2,-1)。(1,5),(2,2),非法后续动作被跳过,先前合法更新与合法兄弟 INSERT 均保留。SELECT 42和新连接健康检查通过。dcb9259f9e7b8d0fe482c784a07fb524a9a0c540,本地 offline 967/967 PASS;未叠加旧 PR374/353。新 PR 的远端检查刚启动,不提前冒称全绿。证据:
qa-33521-constraints/main-ba608/。