Skip to content

[Bug]: DATA BRANCH CREATE TABLE fails for BINARY and VARBINARY primary keys #26075

Closed

Description

@Ariznawlll

Description

DATA BRANCH CREATE TABLE ... FROM ... fails for source tables whose primary key is BINARY or VARBINARY. Ordinary table creation and inserts with these primary-key types succeed, but the branch table is not created.

Environment

  • Branch: main
  • Commit: 2eb7f523e5a10f352d3e258183ed8440510388de
  • Version: 8.0.30-MatrixOne-v1.3.0

Steps to reproduce

DROP DATABASE IF EXISTS g4d_branch_binary_pk;
CREATE DATABASE g4d_branch_binary_pk;
USE g4d_branch_binary_pk;

CREATE TABLE binary_base(k BINARY(4) PRIMARY KEY, v INT);
INSERT INTO binary_base VALUES('a', 10), ('b', 20);
DATA BRANCH CREATE TABLE binary_branch FROM binary_base;

CREATE TABLE varbinary_base(k VARBINARY(8) PRIMARY KEY, v INT);
INSERT INTO varbinary_base VALUES('a', 10), ('b', 20);
DATA BRANCH CREATE TABLE varbinary_branch FROM varbinary_base;

Actual result

Both branch creation statements return an internal error from the merge-sort path:

internal error: panic invalid type: BINARY
internal error: panic invalid type: VARBINARY

The stack starts at pkg/objectio/mergeutil.MergeSortBatches and passes through the sinker spill-sort path.

After each failure, the target branch table does not exist and no active branch metadata remains. The result reproduced in 3 out of 3 runs.

Expected result

Data Branch should create a branch from tables with BINARY and VARBINARY primary keys without returning an internal error, or reject unsupported types with a clear validation error before starting the operation.

Activity

  1. added this to the MO-202607 milestone on Jul 23, 2026
  2. added
    kind/bug
    on Jul 23, 2026
  3. added theissue type on Jul 23, 2026
  4. added
    severity/s0
    ai-easy
    and removed on Aug 1, 2026
  5. added a commit that references this issue on Aug 1, 2026
    49f9e33
  6. added and removed
    severity/s0
    on Aug 2, 2026
  7. gouhongshen commented on Aug 2, 2026

    @gouhongshen
    Contributor

    fixed

  8. Ariznawlll commented on Aug 4, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:c58cd292d3e6e039a8882654d3b20ad345171e87
    • 部署方式:macOS arm64,本地 MatrixOne 单 CN 黑盒环境
    • 测试日期:2026-08-04

    原问题验证

    使用 BINARY/VARBINARY 主键重新执行 DATA BRANCH CREATE TABLE、DIFF 和 MERGE,branch 创建及后续 apply 均成功,没有再出现 binary PK merge/sort 失败。

    Happy Path 覆盖

    1. VARBINARY 主键覆盖 12,000 行、每行 1,024 字节 payload 的多 batch 场景。
    2. 执行 400 行 UPDATE、100 行 DELETE、100 行 INSERT 后 MERGE,目标表与 source 完整相等,DIFF 为 0。
    3. 复合 BINARY(16) 主键覆盖 5,000 行,创建和 MERGE 后完整数据一致。

    Unhappy Path 覆盖

    1. 覆盖包含零字节和非文本字节的 key,未发生 UTF-8 转换或 key 截断。
    2. MERGE 后逐行比较完整数据集,未发现重复、遗漏或 payload 错位。
    3. 多 batch 执行过程中没有 panic、hang 或异常资源增长。

    白盒验证

    执行 TestMergeSortBatchesBinaryTypes,验证 binary/varbinary batch merge-sort;连续执行 3 轮通过。

    回归测试

    测试证据

    测试结论

    测试通过。

  9. added 3 commits that reference this issue on Sep 17, 2026
    1de9831
    8e2f10e
    d64f622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions