Skip to content

[Bug]: FULLTEXT indexed INSERT publishes a hidden index ID through LAST_INSERT_ID (v4.2.5) #29903

Closed

Description

@dengn

Is there an existing issue for the same bug?

  • I searched exact error strings, failing syntax and affected native applications; no matching issue was identified. Related reports are distinguished below.

Application compatibility replay on official v4.2.5

Branch Name

Official stable release v4.2.5; current main has not been retested for this report.

Commit ID

1a44f3db3056e32975fde86ca0ab69a094996a3f (SELECT git_version() returns 1a44f3d).

Other Environment Information

Linux x86_64 standalone official binary, 4 CPUs, ~16 GiB container memory limit. SELECT VERSION() = 8.0.30-MatrixOne-v4.2.5. PyMySQL 1.2.3 client. Only fresh owned test schemas were used for SQL probes; the native Airflow diagnostic is a read-only SELECT against the retained test fixture.

Actual Behavior

Native application impact: 实际任务 10/11 跳转为 348/355;最小表 ID 1/2 返回 2/4。

SELECT id,LAST_INSERT_ID() FROM id_probe
[[1, 2]]
Fresh table: stored base id=1, SELECT LAST_INSERT_ID()=2. The second fresh run reproduced the same values. Native Leantime originally linked task IDs 10/11 to 348/355. The hidden ID symptom is not merely an auto-increment gap.

Expected Behavior

The protocol INSERT ID and LAST_INSERT_ID() must refer to the base table business primary key, not a hidden fulltext posting/index primary key.

Steps to Reproduce

Use a dedicated fresh test schema (create one without DROP DATABASE), then run:

CREATE TABLE id_probe(id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,label VARCHAR(40));

ALTER TABLE id_probe ADD FULLTEXT label_ft(label);

INSERT INTO id_probe(label) VALUES('small');

SELECT id,LAST_INSERT_ID() FROM id_probe;

Additional information

  • Native applications: Leantime.
  • This is release v4.2.5 evidence, not a claim that the same failure remains on current main.
  • Observation family MO-OBS-012. App-side workarounds do not constitute an engine fix.
  • All disclosed values are owned synthetic fixtures; no passwords, tokens, application cookies or raw private logs are attached.

Activity

  1. added
    kind/bug
    on Oct 11, 2026
  2. dengn commented on Oct 12, 2026

    @dengn
    ContributorAuthor

    Runtime recheck on current main

    Built and actually ran upstream main 02a2823c2007d5e4fb4ada148e93743df337551a, with git_version() = 02a2823, Go 1.27.1, Linux amd64, the official make build CPU entrypoint, gcc/g++, and separate fresh main cluster storage. Binary SHA-256: ce8b149f0da8c8a06ec8786c4d311795e6893420bd15be29d6e6b9cab44bb2f5. SQL checks ran 2026-10-12 06:04 UTC; upstream main was re-read before execution and still resolved to this SHA.

    Comparison: official v4.2.5 / 1a44f3db3056e32975fde86ca0ab69a094996a3f (git_version() = 1a44f3d). Both sides used fresh owned schemas and identical regression fixture hashes. This checks the disclosed reproducer; complete native application workflows have not been rerun on main. No issue is being closed automatically.

    SQL-FULLTEXT-INSERT-ID: stable known_failure → main candidate_fixed

    The reproducer completed and its result/constraint assertions passed on this main snapshot; the stable failure no longer reproduces for this fixture.

    Fixture SHA-256: 65e116fc95a7e98bd5444940a3cec82a671bcf1e3219ad87179b5cac0ee7c5af. A fresh SELECT 1 after the trigger succeeded: True.

    SELECT id,LAST_INSERT_ID() FROM id_probe;

    Returned rows: [[1, 1]].

    Detailed SQL, assertions, source/build identity and JSON evidence (organization regression repository): https://github.com/matrixorigin/matrixone-app-regression/tree/01517d2f73abb5021ca545193c2af38ef653f278/evidence/main-02a2823

  3. XuPeng-SH commented on Oct 16, 2026

    @XuPeng-SH
    Contributor

    新合并回补后的复验结果:原始 FULLTEXT INSERT / LAST_INSERT_ID 场景已通过,继续保留转测 @Ariznawlll。

    此前失败结果针对旧 4.2-dev 提交 947517cc457ae75aff0e3667ff91bace1656c705:实际用户行 id=1,但 LAST_INSERT_ID() 与 OK packet insert_id 均为 2。

    本次发现 #30005 已于 2026-10-16 22:33(北京时间)合并,因此没有直接依据旧结果退回开发,而是检出并重新构建、运行其 4.2-dev 合并提交 e2c99334fd23b9260728695e29befd35ab26b454(Linux/amd64、Go 1.26.4,使用本提交对应的 native 构建)。

    在相同原始 SQL 场景下实测:

    CREATE TABLE id_probe(id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,label VARCHAR(40));
    ALTER TABLE id_probe ADD FULLTEXT label_ft(label);
    INSERT INTO id_probe(label) VALUES('small');
    SELECT id,LAST_INSERT_ID() FROM id_probe;

    结果:用户行 id=1、LAST_INSERT_ID()=1、OK packet insert_id=1,三个断言均通过。

    另外实际运行并通过:

    • TestIssue29903InsertIDOkPacket
    • TestIssue29903RetryKeepsEarlierStatementLastInsertID

    结论仅针对上述新合并的 4.2-dev 提交,不表示历史已发布的 v4.2.5 二进制已经改变。保持 OPEN,由测试在目标交付版本验收;本次不退回开发。

  4. Ariznawlll commented on Oct 19, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 官方 main 完整 commit:def799e1260dd547cae2e0e54323ea20ec1b7685;修复 PR fix(insert): exclude fake primary key from LAST_INSERT_ID (#29903) #30004 MERGED,merge commit fd4767e488dc111db02c9119cd46dfe78af1ee23 确认已进入该 main。
    • 官方 4.2-dev 完整 commit:35273bcd6a5cfa9468bcf7ca4031fe17560b5ab1;回补 PR fix(insert): exclude fake primary key from LAST_INSERT_ID (#29903) [4.2-dev] #30005 MERGED,merge commit e2c99334fd23b9260728695e29befd35ab26b454 确认已进入该发布线。
    • 部署方式:两个 commit 分别以自身源码及原生依赖构建,在隔离本地 1 CN / 1 TN / 1 LogService 服务上通过 MySQL 协议连接;另运行仓库内嵌集群测试。未使用共享环境。日期:2026-10-19(北京时间)。
    • 4.2-dev 是本次验证的发布线源码;历史已发布的 v4.2.5 二进制并未被改变,也未把本地构建的版本字符串当作已发布版本号。

    原问题验证

    在全新测试库依次执行原始场景:创建 BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY 表、添加 FULLTEXT label_ft(label)、插入 'small',读取表中 id 与 LAST_INSERT_ID(),并独立检查协议 OK packet 的 insert_id。main 与 4.2-dev 各 3/3 轮,首行实际均为 id=1, LAST_INSERT_ID()=1, insert_id=1;未再发布 FULLTEXT 隐藏索引 ID。

    Happy Path 覆盖

    1. 第二次插入 'second' 后,两个分支各 3/3 轮实际 OK packet insert_id=2,表中两行 ID 为 1、2,同一会话 LAST_INSERT_ID()=2。
    2. label=NULL 边界:两个分支各 3/3 轮实际 OK packet insert_id=3,新行 (id,label,LAST_INSERT_ID())=(3,NULL,3);FULLTEXT 索引存在时仍保持用户表 ID 语义。
    3. 每轮关闭连接、删除专用测试库;发布线服务复查 qa_issue29903_% 残留库数为 0。

    Unhappy Path 覆盖

    1. 在已有 ID=2 后再次显式插入该 ID,两个分支各 3/3 轮返回重复主键错误 1062;失败后 COUNT(*)=3, MAX(id)=3,已提交的原有行与 NULL 行均保留,同连接后续 SELECT 正常。
    2. 本问题不涉及非法文本解析、跨租户授权或外部节点故障;这些维度未冒充已测。原生 Leantime 完整应用工作流本次未重跑,验收依据是其相同的独立 SQL/协议最小复现。

    白盒验证

    • 4.2-dev 的 TestIssue29903InsertIDOkPacket、TestIssue29903RetryKeepsEarlierStatementLastInsertID 分别 -count=3 PASS;涵盖 OK packet、会话 ID 与重试保留语义。
    • main 的 TestIssue29903RetryKeepsEarlierStatementLastInsertID -count=3 PASS。未将这些仓库内测试替代外部协议与 MOTR 结果。

    回归测试

    • 已向 MOTR PR #247 增加 SQL 场景 及配对 结果。独立断言 ID 1/2/3、NULL、1062 后原表行数;main 定向 3/3、42/42 条语句通过。
    • PR head ffd381cafe4473086b3e9e0ccb36c938cb9e1016 仍 Open;离线检查在本次写评论时尚在运行。完整 MOTR suite/集成 CI 未在本轮执行,合入与检查结果后续跟踪。

    测试证据

    • 上述 MOTR PR 的成对测试文件可独立核对预期值;主干与 4.2-dev 修复合并记录分别见 #30004、#30005。
    • 本地外部协议实测日志:两个分支均为 3/3 轮 packet_ids=1,2,3,三行 ID/NULL 精确一致,duplicate=1062 且 state=((3,3),);定向 Go 测试上述各 3/3 PASS。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions