You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Compatibility]: ODKU UPDATE returns the wrong LAST_INSERT_ID #28162
在 MatrixOne main 99ed717b769e261b842c2f17345bd65865fc1470,ODKU 因主键冲突转为 UPDATE 时,LAST_INSERT_ID() 返回了冲突尝试消耗的下一个自增值,而不是实际更新行的自增主键:
CREATETABLEt (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
k VARCHAR(32) UNIQUE,
v INT
);
INSERT INTO t(k,v) VALUES ('x',10); -- id=1INSERT INTO t(k,v) VALUES ('x',11)
ON DUPLICATE KEY UPDATE v=VALUES(v);
SELECT LAST_INSERT_ID();
CREATETABLEmarker(id INT AUTO_INCREMENT PRIMARY KEY) AUTO_INCREMENT=500;
CREATETABLEtarget(
id INT AUTO_INCREMENT PRIMARY KEY,
u INT UNIQUE,
v INT
);
INSERT INTO target(u,v) VALUES(10,1); -- target id=1INSERT INTO marker VALUES(); -- session LAST_INSERT_ID becomes 500SELECT LAST_INSERT_ID(); -- 500INSERT INTO target(u,v) VALUES(10,2)
ON DUPLICATE KEY UPDATE v=VALUES(v);
SELECT id,u,v FROM target; -- 1,10,2SELECT LAST_INSERT_ID(); -- MatrixOne: 2; MySQL 8.3: 500
MatrixOne 把冲突尝试预分配但并未写入的候选 ID 发布为当前语句的 insert ID。MySQL 在未使用 LAST_INSERT_ID(id) assignment 的普通更新分支中保留此前的会话值;无论采用哪种期望,MO 返回不存在于表中的候选 ID 都会让调用方误认该 ID 已被写入。
The PR is still open and unmerged. Its head advanced from c0cf5f828d64f58e14fb030f98d974ab6cdbd5e5 to 47254e28e441e6cfb3a8b5263f45963a21e1bfcb with a 12-commit main integration. The latest commit is titled “Merge main and preserve ODKU result ownership protocol boundaries.”
I checked the exact new head: GitHub currently reports no associated workflow runs and no combined commit statuses; no review has been submitted for this head yet. Results recorded for the previous head are not treated as validation of this merge. This workspace has no MatrixOne checkout or Go runtime, so I did not run tests locally.
The original GC/restart empty-metadata incident remains unresolved/inconclusive, with no attribution or rerun recorded. Issue #28162 stays open and assigned to VioletQwQ-0; no tester handoff until the current head is validated and the fix reaches the merge target.
QA update — PR #28444 validation receipt for head 47254e28e441e6cfb3a8b5263f45963a21e1bfcb
The author’s new PR comment reports this exact head’s normal conflict-maintenance validation: 334 focused named test events, 15 normal owning packages, scoped vet/configured lint, and 466/466 canonical comparisons; three existing owning-test skips were kept separate. The comment says no source/oracle was weakened and no new-head CI pass is claimed.
I checked GitHub independently: the PR is still open/unmerged, and this SHA currently has no workflow runs or combined status checks. These repository-authored validation receipts are not my local execution; this workspace has no MatrixOne checkout or Go runtime.
The comment also leaves formal review, representative performance/resource qualification, genuine predecessor/layout testing and deployed QA as separate gates. The original GC/restart empty-metadata incident remains inconclusive and un-attributed. Issue #28162 stays open and assigned to VioletQwQ-0; no tester handoff is appropriate before merge-target verification.
QA checkpoint — PR #28444 synchronized to 8030407a39878935365e866b8d27beaa12ced2da
The PR remains open and unmerged. The new head is a merge of main; comparison from the previous recorded head 47254e28e441e6cfb3a8b5263f45963a21e1bfcb shows 8 commits, so evidence tied to the previous SHA is not treated as validation of this tree.
For the exact current SHA, GitHub reports no combined commit status checks. The associated PR workflow list has Connector/J Pool Reset E2E in progress and Iceberg Connector E2E successful; neither is an ODKU-specific validation result. I did not run tests locally: this workspace has no MatrixOne checkout or Go runtime.
The prior ODKU regressions and the separate GC/restart empty-metadata incident remain tracked; the latter is still inconclusive/unattributed. Current-head CI, formal review, representative performance/resource qualification, predecessor/layout testing and deployed QA remain outstanding. Issue #28162 remains open and assigned to VioletQwQ-0; no tester handoff is made before the fix is validated on the merge target.
QA handoff for merged #28444 (9cf8743ed7b6b4269f50179f1b09664a7582f4e7, batch 043fc9d3b9327bb7e542bc46ec3b73526c637ddc): targeted protobuf roundtrip and six internal process tests passed using a full Go source overlay; the base module graph retained an unused extra dependency. A separate preinsert compile stopped at the memory guard before assertions, without OOM. Actual SQL/OK-packet and JDBC generated-key behavior, distributed retry and mixed-version execution remain unverified locally; please verify against the original contract. No full-system pass is claimed.
Activity
Ariznawlll commentedon Sep 5, 2026
补充客户端可见的返回值现象,运行版本为官方 main
e7bb0572235ec4bac81eb098eb0ad8900f0065ab,对照 MySQL 8.3.0、Connector/J 8.3.0。表定义:
第二条 INSERT 只更新已有的
id=1,并未插入id=2。此时 MO 的 OK packet insert-id、LAST_INSERT_ID()返回2,MySQL 对应返回1。JDBCgetGeneratedKeys()的首个值也分别是 MO 的2和 MySQL 的1。应用若将 MO 返回的首个 generated key 用于后续查询,会查询到并不存在的行。JDBC 分别组合
rewriteBatchedStatements、useServerPrepStmts、useAffectedRows、continueBatchOnError的两种取值,共 16 种配置、每种重复 3 次;在各配置下,单条重复键更新后getGeneratedKeys()都出现上述首值差异,表内数据仍是id=1。完整驱动返回序列为 MO[2,3]、MySQL[1,2];两端驱动都枚举出两个值,因此不能将“返回两个键”本身单独归为 MO 差异。这里能独立确认的服务端差异是 OK packet 的起始 ID 错误。另以 SQL 客户端重复 3 次得到同样现象。这里关注的是返回的 ID 与实际被更新行不对应,不把 AUTO_INCREMENT 预分配或序列空洞本身认定为问题。开启
CLIENT_FOUND_ROWS后无变化 ODKU 的 affected-rows 问题已独立记录在 #28180。Ariznawlll commentedon Sep 5, 2026
最新
main(e7bb0572235ec4bac81eb098eb0ad8900f0065ab)仍存在该会话状态错误,并且用不重合的旧会话值可以排除“恰好返回了旧值”的歧义:MatrixOne 把冲突尝试预分配但并未写入的候选 ID 发布为当前语句的 insert ID。MySQL 在未使用
LAST_INSERT_ID(id)assignment 的普通更新分支中保留此前的会话值;无论采用哪种期望,MO 返回不存在于表中的候选 ID 都会让调用方误认该 ID 已被写入。相同场景连续执行时,MO 会继续把 3、4 等未落表候选值写入会话状态,而实际被更新行的主键始终为 1。
XuPeng-SH commentedon Oct 23, 2026
QA update — PR #28444 synchronized
The PR is still open and unmerged. Its head advanced from
c0cf5f828d64f58e14fb030f98d974ab6cdbd5e5to47254e28e441e6cfb3a8b5263f45963a21e1bfcbwith a 12-commit main integration. The latest commit is titled “Merge main and preserve ODKU result ownership protocol boundaries.”I checked the exact new head: GitHub currently reports no associated workflow runs and no combined commit statuses; no review has been submitted for this head yet. Results recorded for the previous head are not treated as validation of this merge. This workspace has no MatrixOne checkout or Go runtime, so I did not run tests locally.
The original GC/restart empty-metadata incident remains unresolved/inconclusive, with no attribution or rerun recorded. Issue #28162 stays open and assigned to
VioletQwQ-0; no tester handoff until the current head is validated and the fix reaches the merge target.XuPeng-SH commentedon Oct 23, 2026
QA update — PR #28444 validation receipt for head
47254e28e441e6cfb3a8b5263f45963a21e1bfcbThe author’s new PR comment reports this exact head’s normal conflict-maintenance validation: 334 focused named test events, 15 normal owning packages, scoped vet/configured lint, and 466/466 canonical comparisons; three existing owning-test skips were kept separate. The comment says no source/oracle was weakened and no new-head CI pass is claimed.
I checked GitHub independently: the PR is still open/unmerged, and this SHA currently has no workflow runs or combined status checks. These repository-authored validation receipts are not my local execution; this workspace has no MatrixOne checkout or Go runtime.
The comment also leaves formal review, representative performance/resource qualification, genuine predecessor/layout testing and deployed QA as separate gates. The original GC/restart empty-metadata incident remains inconclusive and un-attributed. Issue #28162 stays open and assigned to
VioletQwQ-0; no tester handoff is appropriate before merge-target verification.XuPeng-SH commentedon Oct 23, 2026
QA checkpoint — PR #28444 synchronized to
8030407a39878935365e866b8d27beaa12ced2daThe PR remains open and unmerged. The new head is a merge of
main; comparison from the previous recorded head47254e28e441e6cfb3a8b5263f45963a21e1bfcbshows 8 commits, so evidence tied to the previous SHA is not treated as validation of this tree.For the exact current SHA, GitHub reports no combined commit status checks. The associated PR workflow list has Connector/J Pool Reset E2E in progress and Iceberg Connector E2E successful; neither is an ODKU-specific validation result. I did not run tests locally: this workspace has no MatrixOne checkout or Go runtime.
The prior ODKU regressions and the separate GC/restart empty-metadata incident remain tracked; the latter is still inconclusive/unattributed. Current-head CI, formal review, representative performance/resource qualification, predecessor/layout testing and deployed QA remain outstanding. Issue #28162 remains open and assigned to
VioletQwQ-0; no tester handoff is made before the fix is validated on the merge target.fix(sql): separate ODKU OK insert ID from session baseline (#28444)
XuPeng-SH commentedon Oct 28, 2026
QA handoff for merged #28444 (
9cf8743ed7b6b4269f50179f1b09664a7582f4e7, batch043fc9d3b9327bb7e542bc46ec3b73526c637ddc): targeted protobuf roundtrip and six internal process tests passed using a full Go source overlay; the base module graph retained an unused extra dependency. A separate preinsert compile stopped at the memory guard before assertions, without OOM. Actual SQL/OK-packet and JDBC generated-key behavior, distributed retry and mixed-version execution remain unverified locally; please verify against the original contract. No full-system pass is claimed.Ariznawlll commentedon Nov 3, 2026
结论
测试通过。最新 main 在本 issue 的普通 ODKU UPDATE 场景中,将 OK packet 的更新行 ID 与会话
LAST_INSERT_ID()分开处理;文本、二进制预处理和 JDBC 对照均与 MySQL 一致。关键证据
main@1876b2f93e14c03ba538e3806e245e3c3203979a,包含 #28444 的合并提交9cf8743ed7b6b4269f50179f1b09664a7582f4e7;本地隔离 1 Log / 1 TN / 2 CN、macOS / Apple Silicon,独立 MySQL 8.0.45 对照。LAST_INSERT_ID()仍为 500。无变化 ODKU 的 packet id 为 0、会话值仍为 500;后续真正插入新行的 packet/session ID 与落表 ID 一致。文本和二进制预处理协议分别重复 3 轮。rewriteBatchedStatements、useServerPrepStmts、useAffectedRows、continueBatchOnError各取两值,共 16 组 × 3 轮 × 两个数据库;每轮核对有变化和 no-op ODKU 的 generated keys、affected rows、会话值及表内容,MO 与 MySQL 全部一致。包含默认配置下有变化更新的 generated keys 序列[1, 2],首值与实际行 ID 相符;不把驱动枚举两个值本身归为本 issue 的差异。CLIENT_FOUND_ROWS的独立会话中 no-op affected rows 为 1,packet id 为 0,且不改该会话 marker。pkg/sql/compile远程 ODKU 结果协议、终止/取消/重试,以及pkg/vm/process会话结果汇总测试使用-race -count=3通过。受控失败注入不等同于生产故障演练。CLIENT_FOUND_ROWS,在两个 CN 各重复 3 次通过;PR 当前 head 的四项离线 CI 通过。待解决点
LAST_INSERT_ID(expr)set-form 在 MO 仍报 20203,属于已有独立 #30802,本次不把该未实现形式计入普通 ODKU UPDATE 的修复通过范围。