Skip to content

[Feature Request]: Pin 4.2 COMPRESS bytes and add opt-in COMPRESS_V2 #33557

Backlog

Description

@XuPeng-SH

Goal

Land SQL compression compatibility as a standalone change on 4.2-dev ahead of the Go 1.27.1 upgrade in #33538. Support the current Go 1.26.4 toolchain and verify the same behavior under Go 1.27.1.

Why this is needed

COMPRESS() currently uses Go's standard-library DEFLATE encoder. In a local shutdown upgrade from v4.2.9 to Go 1.27.1 without pinning the encoder, 40 ASCII A characters compressed to 13 bytes before the upgrade and 51 bytes after it. A lookup by HEX(COMPRESS(s)) missed an existing stored unique key, and a second insert of the same source value succeeded. The same encoded value also stopped fitting in VARBINARY(32). Reproduction details in #33538

Scope

  • Pin the encoder used by COMPRESS() to the released 4.2 behavior. Preserve existing bytes, SQL function identity, and generated-column expressions.
  • Add opt-in COMPRESS_V2() using level 6 of the existing klauspost/compress v1.18.7 dependency. Give the new function its own persistent identity.
  • Add UNCOMPRESS_V2() to read complete V1 and V2 streams into a BLOB, with bounded output and input validation. Track the fix for the original UNCOMPRESS() separately in [Bug]: 4.2-dev UNCOMPRESS returns NULL for valid multi-block COMPRESS output #33555.

Acceptance

  • Resolve the V2 function ID collision in this standalone compression PR. The draft in [4.2-dev] build: upgrade to Go 1.27.1 #33538 used 638 for COMPRESS_V2, and 4.2-dev now assigns 638 to IVF_EXACT_PK_IN. Allocate separate free IDs for both V2 functions against the current 4.2-dev and main registries. Keep the existing IVF and compression IDs stable, and carry the final V2 IDs and overload order forward in D24 ([Subtask]: D24 [4.2-to-main] Preserve SQL compression contracts across the next major upgrade #33558). Collision evidence
  • Verify exact V1 and V2 bytes and round trips with both Go 1.26.4 and Go 1.27.1. Include binary data, empty and NULL values, multi-block streams, and corrupt input.
  • Reopen a released 4.2 data directory and verify that stored V1 keys remain searchable and reject duplicates. Verify that stored V2 expressions retain their identity across restart and logical restore.
  • Measure single-row and batch SQL performance and compressed size with both encoders. The existing 256-row article-text workload measured a p50 of 16.19 ms with V1 and 11.04 ms with V2. Measurements in #33538

Land this issue's standalone PR before merging the Go 1.27.1 upgrade in #33538. Rebase the upgrade on the merged compression change.

Activity

  1. self-assigned this
    on Dec 1, 2026
  2. XuPeng-SH commented on Dec 1, 2026

    @XuPeng-SH
    ContributorAuthor

    独立验收补充,范围是 Go 1.26.4 的最终合入版本。用官方 v4.2.9 Linux/amd64 (6c05e42) 创建含 HEX(COMPRESS(s)) 的 STORED UNIQUE 列和 VARBINARY(32) 对照,干净停机。使用 精确合并等价制品(build 024971e7,与 4.2-dev 合并 efbab93e 同树)打开同一原始数据目录。两侧二进制 .go.buildinfo 都是 Go 1.26.4。

    • REPEAT('A',40) 得到相同的 13 字节 V1 帧 2800000072241200020000FFFF;重算键仍找到原行;重复源值仍返回 1062。旧压缩行可解出 40 字节,新压缩行仍能写入 VARBINARY(32)。
    • V2 生成的唯一键在合入版停机重启后保持字节一致并仍拒绝重复;SHOW CREATE TABLE 加逻辑行重放能在新表重建同一帧。UNCOMPRESS_V2 解码 V1/V2 均保留 00FF80,不完整输入与 NULL 对照按预期返回 NULL。三次服务日志均确认 Shutdown complete。
    • 未独立验证 Go 1.27.1 的实际二进制 reopen、正式备份恢复入口或性能,本结果不替代 [4.2-dev] build: upgrade to Go 1.27.1 #33538 的双工具链闸门。工单继续保留当前负责人。
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