Skip to content

[Bug]: nullable VARCHAR CASE aggregate panics with bitmap external storage capacity exceeded #27432

Closed

Description

@Lundomn

Description

A valid aggregate over a nullable VARCHAR condition can abort with an internal Bitmap panic instead of returning the correct result.

Environment

  • Repository: matrixorigin/matrixone
  • Branch: main
  • Commit: 1b142c5e4ee29f1f9ccc49b9eeeae349fb033a7c
  • Deployment: local standalone MatrixOne service, one CN/TN/log service
  • SQL endpoint: 127.0.0.1:6004
  • Dataset: Kafka-derived GH Archive projection (590,187 deterministic sequence slots; 559,124 loaded rows)
  • Table: mo_gharchive_correctness_8798.github_events

The initial 6004 executable was built from the commit above before a separate uncommitted source experiment.

Reproduction

USE mo_gharchive_correctness_8798;

SELECT SUM(CASE WHEN action = 'opened' THEN 1 ELSE 0 END)
FROM github_events;

Actual behavior

The query fails consistently (3/3 executions):

ERROR 20101 (HY000):
internal error: panic bitmap external storage capacity exceeded

The same condition grouped by event_type and source_hour also fails. A reduced derived-table shape still fails:

SELECT SUM(CASE WHEN action = 'opened' THEN 1 ELSE 0 END)
FROM (SELECT action FROM github_events LIMIT 1) AS x;

Expected behavior

The query should return:

31093

There are 31,093 rows where action = 'opened'.

Controls

All of the following return the correct value 31093:

SELECT COUNT(*) FROM github_events WHERE action = 'opened';

SELECT SUM(CASE WHEN COALESCE(action, '') = 'opened' THEN 1 ELSE 0 END)
FROM github_events;

-- seq is NOT NULL and this upper bound covers every loaded row
SELECT SUM(CASE WHEN action = 'opened' THEN 1 ELSE 0 END)
FROM github_events
WHERE seq < 590187;

A plain projection (SELECT action = 'opened' ...) also succeeds. The same action data in a simpler comparison table succeeds, indicating a vector/storage-layout-sensitive execution bug rather than invalid input.

Stability

  • Latest-main executable: 3/3 failures.
  • Existing 6001 service: same query reproduced 3/3 with the same Bitmap-capacity error.
  • action is nullable: 460,938 NULLs, 98,186 non-NULL values, 31,093 opened values.

Source-level analysis

The stack is:

bitmap.Bitmap.TryExpandWithSize
bitmap.Bitmap.Or
nulls.Or
function.opBinaryStrStrToFixed
function.equalFn
FunctionExpressionExecutor.EvalCase
group.Group.evaluateGroupByAndAggArgs

The nullable string comparison merges NULL bitmaps. The result bitmap uses external storage; attempting to expand it beyond the external capacity panics instead of producing a valid aggregate result.

Activity

  1. reopened this on Sep 4, 2026
  2. Ariznawlll commented on Sep 9, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • commit:cd04bb4c1af5bc595e2147dc645dfa754f4c395b
    • 部署方式:本地单 CN/TN/Log 隔离环境
    • 测试日期:2026-09-09

    原问题验证

    构造原问题同量级数据:590187 个 sequence slot、559124 行可见记录、460938 个 NULL action、98186 个非 NULL action、31093 个 opened。SUM(CASE WHEN action='opened' THEN 1 ELSE 0 END) 连续 3 轮返回 31093,无 bitmap external-storage panic。

    Happy Path 覆盖

    1. 原 CASE 聚合、COALESCE(action, '') 对照、派生表、按 event_type/source_hour 分组聚合均返回总数 31093。
    2. 三轮数据完整性均为 559124/31093/98186/460938(总行/ opened/非 NULL/NULL)。
    3. MOTR 新用例连续执行 3 轮通过(每轮 14 statements)。

    Unhappy Path 覆盖

    1. 聚合引用不存在列返回 ERROR 1054;错误后同一高数据量表仍可返回 opened=31093、action = NULL 为 0、action IS NULL 为 460938。

    白盒验证

    修复前父提交 705d5fbb625d32090b9a8acadcead08c3e1d4535 上,最小 external bitmap 合并测试稳定触发 panic: bitmap external storage capacity exceeded;当前 main 运行 TestOrTruncatesLongSourceForExternalResult、TestOrTruncatesLongSourceForExternalResultWithTwoInputs、TestOrExternalResultBoundaryCases 均通过。

    回归测试

    • MOTR:PR #152
    • suites/14_issue_regression/t/issue_27432_nullable_varchar_case_aggregate.test
    • 单用例 3/3 通过;14_issue_regression 套件中该用例通过。

    测试证据

    测试结论

    测试通过。

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