Skip to content

[Bug]: MD5(LONGBLOB) hashes only the first 65535 bytes #27798

Closed

Description

@Lundomn

Is there an existing issue for the same bug?

  • Searched open and closed issues; no matching report was found.

Branch Name

main

Commit ID

e5f26b66195373f9bff512ac9f428788d1c07e8c

Other Environment Information

  • macOS ARM64, standalone MatrixOne
  • MatrixOne protocol version 8.0.30-MatrixOne-v
  • MySQL 8.0.42 control

Actual Behavior

For a stored 65,536-byte LONGBLOB, MatrixOne returns the MD5 of only the first
65,535 bytes.

Expected Behavior

MD5(payload) should hash all bytes and match MySQL and the client-side MD5.

Steps to Reproduce

CREATE TABLE md5_blob_repro(payload LONGBLOB);
INSERT INTO md5_blob_repro
VALUES (CONCAT(REPEAT('a',32768),REPEAT('a',32768)));

SELECT LENGTH(payload),
       MD5(payload),
       MD5(CONCAT(REPEAT('a',32768),REPEAT('a',32768))) AS expected
FROM md5_blob_repro;

MatrixOne:

65536 | 22686eba65441cdc1795f276dcdd4e45 | 2d61aa54b58c2e94403fb092c3dbc027

MySQL 8.0.42 returns 2d61aa54b58c2e94403fb092c3dbc027 for both MD5
columns. The MatrixOne value is exactly the MD5 of 65,535 a bytes. Retrieved
payload bytes and client SHA-256 remain correct.

Additional information

Tracker: #27746. T18 tested 0, 1, 255, 65,535, 65,536, and 1 MiB payloads;
the mismatch begins at 65,536 bytes.

Activity

  1. self-assigned this
    on Aug 28, 2026
  2. added a commit that references this issue on Aug 31, 2026
    743789e
  3. reopened this on Sep 4, 2026
  4. assigned and unassigned on Sep 4, 2026
  5. slyunnn commented on Sep 8, 2026

    @slyunnn

    Regression and extended verification for #27798 (2026-09-08)

    Verification Environment

    • MatrixOne baseline: latest origin/main at 80d214bef28a33f81020b76b2ed9280a6e7654b9 — fix: return NULL for POWER EXP and COT arithmetic failures (#28375).
    • Related fix: PR #27883, fix(function): prevent md5 truncation for text and blob, merge commit 743789eb8f0ff7cacc7b062b244e965c9033566d; it is an ancestor of the verified origin/main.
    • Topology: fresh local 1 LogService + 1 TN + 1 CN deployment, with no Proxy and one CN frontend at 127.0.0.1:26001.
    • Three test endpoints/entry points: direct mysql client at 127.0.0.1:26001; MOTR record client at 127.0.0.1:26001; MOTR replay client (run twice) at 127.0.0.1:26001. They intentionally resolve to the same physical CN because this is a single-CN topology.
    • Client protocol: MySQL TCP text protocol (mysql CLI and MOTR/PyMySQL). The focused function unit test additionally verified direct MD5 overload dispatch.

    What Was Covered

    • OK: Original stored 65536-byte LONGBLOB and LONGTEXT reproduction returned 2d61aa54b58c2e94403fb092c3dbc027, not the 65535-byte digest.
    • OK: Boundary lengths 0, 1, 255, 65535, 65536, and 65537 for both LONGBLOB and LONGTEXT matched independently computed MD5 constants.
    • OK: LONGBLOB and LONGTEXT stored-value lengths and digests matched for every boundary row.
    • OK: Compatibility control MD5('abc') retained the expected VARCHAR behavior.
    • OK: Boundary/unhappy control MD5(NULL) returned NULL.
    • OK: A stored 1048576-byte (1MiB) LONGBLOB and LONGTEXT value matched client MD5 7202826a7791073fe2787f0c94603278.
    • Not covered: Multi-CN/Proxy routing; hashing is a local scalar function and the verified topology has one CN and no Proxy.

    Findings

    The original truncation regression is not reproducible on the current mainline. The direct TEXT and BLOB MD5 overloads avoid the former implicit conversion to VARCHAR, so stored long objects are hashed in full.

    Focused current-main function tests passed: TestMd5 and TestMd5LargeStringUsesFullValue, including both text and blob subtests (1.611s).

    MOTR / BVT Coverage

    Added and recorded:

    • suites/14_issue_regression/t/issue_27798_md5_large_objects.test
    • suites/14_issue_regression/r/issue_27798_md5_large_objects.result

    The case was recorded once and replayed twice successfully: 9 statements per replay, 9 passed, 0 failed. The regression commit is ec97371881f61669beddc377237dc003d4269ee3 (test: add MOTR regression for #27798) on test/issue-27798-md5-large-objects, pushed to matrixorigin/motr via SSH.

    Large-data regression: required and executed. The failure is determined by byte length, with the transition at 65536, so the test includes 65535, 65536, 65537, and a 1MiB value as the minimum stable size coverage beyond the truncation boundary. It uses one row per size and adds no unrelated row-count, concurrency, spill, or network load.

    Final Conclusion

    Fixed. The mainline fix hashes complete stored LONGBLOB and LONGTEXT values across the reported boundary and the 1MiB scale check. Multi-CN/Proxy routing remains explicitly not covered because it is outside this scalar-function contract.

  6. added 3 commits that reference this issue on Sep 17, 2026
    4dbde25
    e0bb9e9
    075f1d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions