Repository navigation
fix(sql): preserve accepted INSERT IGNORE rows across constraint failures - #33528
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 6541715e5d87c0895aa9e61fe7ad7a0b881d43e1
Assessment: approve
No actionable regression was established. The change reuses existing foreign-key joins and witness locks, while adding an accounted parent-key set for computed updates that must be evaluated against earlier accepted actions.
Model: gpt-6.1-terra / max
Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45
Validation:
-
Private /tmp and loopback preflight passed.
-
Focused deduplication, ordered-insert and planner tests passed: checks/1796048354689926552-3.json and focused-tests.log.
-
A single-CN SQL probe passed for ordered CHECK and FK rejection, warning counts, generated IDs and an uncommitted parent: checks/1796048491162046955-3.json and sql-probe.log.
-
A concurrent parent-delete probe passed, including a final rejected update after an accepted FK change: checks/1796048799960717380-5.json and lock-rejected-last.log.
-
New plan and pipeline fields passed a wire round-trip probe: checks/1796048753903985538-3.json and wire-probe.log.
-
A two-CN SQL probe passed with multi-CN scheduling enabled: checks/1796049471888169015-4.json and multicn-standard.log.
-
git diff --check passed; the assigned checkout remained clean.
Limitations:
-
A coordinator-draining two-CN variant timed out on both the candidate and a pinned-base source overlay. The captured stacks show runtime-filter waits, but the root cause was not established; the successful normal two-CN run does not validate that forced variant.
-
The full BVT suites, MySQL differential workload, benchmarks and race tests reported in the PR were not independently repeated; local_validation contained no retained author runs.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 5d83c369c027057c9476c3f6a8d364642c2e0c6f
Assessment: request_changes
The ordered-action design reuses existing arbiters and parent witness locks, while the bounded membership lookup supports action-specific foreign-key checks. The reviewed paths passed focused validation, but the change extends a protocol gate contrary to the pinned upgrade policy, and the new distributed test expects an error on a clean run. The earlier approval applied to a prior head and does not cover the current planner and membership changes.
Model: gpt-6.1-terra / max
Session: 01a22af4-cf2a-7f70-88e4-931bbf57d739 · slot 2 · generation 14
-
P2
pkg/sql/plan/bind_insert.go:2486: An ordinary INSERT IGNORE checks a non-self-referencing foreign key, and the local MOProtocolVersion is missing or below 125.
Impact: The statement now fails during binding, introducing a version-dependent failure branch and maintenance dependency on a path that previously did not use this gate. This is a policy and design issue; it is not evidence of a failure in a supported shutdown-only upgrade.
Evidence: At the pinned base, the version check and _load_fk_ignore_check were used only when loadWarnings was true. The shared binder now uses both for ordinary INSERT IGNORE, and pkg/sql/colexec/evalExpression.go:522 applies the gate again when constructing the executor. The pinned .agents/skills/mo-dev/references/upgrade-compatibility.md:94-109 explicitly says existing gates must not be extended to new features. Preserve the existing LOAD behavior while allowing ordinary INSERT diagnostics without extending that gate. -
P2
test/distributed/cases/dml/insert/insert_ignore_constraint_actions.result:2: The new distributed test runs when insert_ignore_constraint_actions does not already exist, including after its own final DROP DATABASE.
Impact: CREATE DATABASE succeeds, but the checked-in result expects an already-exists error, so a clean result comparison cannot pass. The test also depends on leftover database state despite the repository's self-contained test requirement.
Evidence: The SQL file starts with CREATE DATABASE and drops that database at line 103. The retained one-CN SQL probe confirmed that a clean CREATE succeeds and a duplicate CREATE errors (public-probe.log; checks/1796051782323603509-3.json). Initialize the fixture from a clean state, then regenerate its expected result.
Validation:
-
Isolation preflight passed (preflight.log; checks/1796051379849653097-3.json).
-
Focused non-race tests passed for the affected lookup, deduplication, unique-insert, hash-build and planner packages (focused.log; checks/1796051697671546362-3.json).
-
One-CN public SQL probes, including the 65-key membership transition, passed (public-probe.log and warning-probe.log; checks/1796051782323603509-3.json and checks/1796051935886880564-3.json).
-
The two-CN computed-FK probe and one-CN parent witness-lock probe passed (multicn.log and lock-probe.log; checks/1796052001256259650-3.json and checks/1796052067433587491-3.json).
-
Wire round-trip and selected compiler tests passed; selected lookup and arbitration tests also passed under the race detector with count=10 (wire-compile.log and focused-race.log; checks/1796052021415944379-3.json and checks/1796052210669868907-3.json).
-
git diff --check passed for the assigned base and head (diff-check.log; checks/1796052521392001020-3.json).
Limitations:
-
The complete distributed BVT suite and an external MySQL differential run were not performed.
-
The earlier review reported that a forced coordinator-drain two-CN control timed out on both its candidate and baseline. The current normal two-CN probe passed, but it did not exercise that variant.
-
Mixed CHECK and foreign-key warnings were observed in stage order. Existing repository fixtures do not establish a universal input-row warning order, so that observation is not reported as a defect.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: b5946447f5156e24407ba9ca54b09b9f4c2e8bc7
Assessment: approve
No actionable defects remain. The change extends the existing ordered insert arbiters and parent-witness locking to handle rejected CHECK and foreign-key actions. The bounded, demand-driven parent lookup supports validation of successive update images without introducing a separate locking mechanism. The prior findings concerning the LOAD protocol gate and BVT fixture isolation are resolved.
Model: gpt-6.1-terra / max
Session: 01a22b07-00b6-7e32-b0a1-3099d0b867c7 · slot 1 · generation 39
Validation:
-
Isolation preflight and the native-input provenance audit passed against the frozen head.
-
Focused tests passed across seven packages, covering admission, foreign-key lookup, hash equality, planning and diagnostics. Selected race tests passed across four affected packages.
-
Public SQL tests passed for CHECK and foreign-key rejection, witness locking, Unicode comparison, automatic IDs, protocol v124 and two-CN execution. Plan, compiler and protobuf checks also passed.
-
git diff --check passed. Command receipts and retained logs are in the diagnostic directory.
Limitations:
-
The author reports successful mo-tester suites and benchmark runs, but their raw logs were not supplied; the exact mo-tester case was not independently repeated.
-
An earlier forced coordinator-drain comparison timed out on both the baseline and candidate, so it did not establish a regression. The normal two-CN test passed.
-
An initial public-test command failed before compilation because it used the wrong shell syntax and Go toolchain. The corrected isolated run passed.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #33521
Fixes #33522
Fixes #33523
Related to #28159 and #28238. Main already accepts the combined syntax through #28482. #28349 fixed the original duplicate-only generated-ID example. This PR also addresses accepted-row ID assignment for plain
INSERT IGNOREwhen an independent CHECK or FK rejects input.What this PR does / why we need it:
Each ignored action must either publish one valid result or leave the last accepted row, its keys and counters intact. Previously plain insert could omit warning 1452, an orphan could abort valid siblings, and a failed duplicate-update CHECK could still write the rejected value.
Ordinary
INSERT IGNOREandLOAD DATA IGNOREshare the FK diagnostic implementation. Only the existing LOAD function requires protocol v125. Parent membership uses the hash join iterator’s SQL equality rules for signed zero and NaN.Validation
CLIENT_FOUND_ROWS.Performance
These measurements compare main
c22be4264eto the demand-driven implementation at5d83c369c0. Two local standalone clusters ran the same SQL in alternating order with 500,000 real parent PKs. In the second round the binaries exchanged cluster slots. Each number is the median of 48 timed statements after eight warmups, in milliseconds.The original extra full-parent pass is gone. Fixed-target ordinary updates still measured slower in these two rounds. In a separate varied-target test the median paired differences were −0.32 ms for the PK and −0.08 ms for the secondary UNIQUE. For a fixed PK, 20 paired physical profiles measured DEDUP at 0.030 / 0.032 ms on main / PR. These data do not establish that the remaining end-to-end difference is required for correctness.
On 500,000 parent keys,
EXPLAIN PHYPLAN ANALYZEfor a duplicate changing only an ordinary column shows one parent hash build in main and in this revision. The first PR revision did two. The remaining build belongs to final FK validation. For a changed scalar FK, both forms of the computed assignment use one final parent build and a keyed membership probe.For dense demand, the lookup switches from key probes to one accounted parent set after 64 distinct scalar keys. Composite or coerced keys use the canonical set at first demand. Bulk tests used 1, 64, 65, 256 and 8,192 rows against 1,000 and 500,000 parents. For 8,192 fresh rows against 500,000 parents, the final FK witness loop already present in main dominated the physical profiles (6.59 s on main and 7.56 s here). The new DEDUP stage took 27 ms in that PR profile. A five-sample autocommit run measured medians of 8.31 / 10.38 s. In a separate paired run within transactions, with rollback outside the measured insert, the medians were 11.29 / 8.67 s. The measurements do not establish a general bulk speedup.
Self-referencing FKs continue through the existing post-write validation. Explicit NULL coercion in ODKU assignments to NOT NULL columns, ODKU provisional IDs, and the allocator high watermark after an explicit positive ID retain their existing behavior.