Repository navigation
Description
Description
LOAD DATA ... IGNORE importing a mixture of valid and foreign-key-invalid child rows fails with ERROR 1452 and rolls back the valid row. MySQL 8.3.0 skips the invalid row and imports the valid row; MatrixOne's own INSERT IGNORE already does the same. This makes an otherwise valid bulk import fail and omit valid data.
Environment
- Branch: official
main - Commit:
3a1e42b4308bd0098e055ddb9360a07f85201d9c - Deployment: isolated local 1 LogService / 1 TN / 2 CN (SQL ports 6301/6302)
- Comparator: isolated MySQL 8.3.0, InnoDB
- Date: 2026-10-21
Steps to reproduce
Create an accessible UTF-8 CSV file /tmp/load_fk_orphan.csv with exactly:
10,1
20,999
Run in a fresh database (adjust the file path to an absolute path accessible to the server):
CREATE TABLE p (id INT PRIMARY KEY);
INSERT INTO p VALUES (1);
CREATE TABLE c (id INT PRIMARY KEY, pid INT,
FOREIGN KEY (pid) REFERENCES p(id));
LOAD DATA INFILE '/tmp/load_fk_orphan.csv' IGNORE
INTO TABLE c FIELDS TERMINATED BY ',';
SELECT id, pid FROM c ORDER BY id;Actual behavior
MatrixOne: ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails. The subsequent SELECT returns zero rows, including no (10,1).
MySQL 8.3.0: LOAD DATA ... IGNORE succeeds and SELECT returns exactly (10,1); it skips only orphan (20,999).
Expected behavior
With IGNORE, skip the foreign-key-invalid row and retain the valid row, consistent with MySQL and MatrixOne's INSERT IGNORE path. Without IGNORE, rejecting the statement and leaving the table empty is correct.
Verification and controls
Reproduced on 3/3 independently created database pairs on the same MatrixOne commit and MySQL comparator. Every pair checked the final MatrixOne rows through the second CN; 60/60 recorded setup/control/observation assertions passed.
- Plain
LOAD DATAon the same two-row file: both engines return 1452 and leave the table empty. LOAD DATA IGNOREon a valid-only file: both import(10,1).INSERT IGNORE INTO c VALUES (10,1),(20,999)in a separate child table: both retain(10,1)and skip the orphan.- After the failed MatrixOne import, both CN reads and a fresh
SELECT 1work; the statement is atomic, so this report is not about constraint corruption or server availability.
Focused white-box observation: pkg/sql/plan/bind_load.go resets builder.isInsertIgnore = false for LOAD, while the modern insert path in pkg/sql/plan/bind_insert.go chooses the row-filtering buildInsertIgnoreFkFilter only for onDupAction == IGNORE; the other branch uses buildModernChildFkAssert and returns 1452. This is a likely policy-path mismatch, not a proven sole root cause.
Evidence: /private/tmp/mo-sequence-run2-20261020/ten-bugs-1021/load-ignore-fk-repeat.jsonl and /private/tmp/mo-sequence-run2-20261020/ten_bug_load_ignore_fk_repeat_1021.py (local reproducer; paths are local to the test host).
This is distinct from open #25470 (duplicate PK/UK behavior of LOAD DATA IGNORE/REPLACE) and closed #30345 (CHECK-violating rows persisted under LOAD DATA IGNORE). The compatibility-contract document does not list this FK case as an accepted limitation.
Regression coverage suggested
Add a LOAD DATA IGNORE FK happy/unhappy test with mixed valid/orphan rows, plain-LOAD atomicity control, INSERT IGNORE control, and cross-CN final-state check. No repository test or PR was added during this investigation.
Activity
XuPeng-SH commentedon Oct 22, 2026
This report is now tracked together with #30500. The canonical issue retains explicit acceptance cases for the behavior described here. This is an administrative duplicate/consolidation closure only; the underlying defect is not claimed fixed. The original description and discussion remain available on this issue.