Skip to content

[Bug]: async IVFFLAT INCLUDE cannot maintain BIT values containing quote or backslash bytes #29015

Closed

Description

@Ariznawlll

Environment

  • MatrixOne commit: 01d60e1c4ded1b0f3fc1a4ecd75ce54e95e23b90
  • Deployment: local shared-TN cluster with two CNs
  • Scope: asynchronous IVFFLAT INCLUDE maintenance through ISCP

Problem

IVFFLAT declares BIT as a supported INCLUDE type, but asynchronous index
maintenance cannot process BIT values whose byte representation contains a
single quote (0x27) or backslash (0x5c). The entries table remains empty for
the initial replay, or stops receiving later DML after a synchronous rebuild.

Safe BIT bytes such as 0x00, 0x01, and 0xff complete in the same cluster.
A synchronous IVFFLAT build also stores 0x27 correctly, isolating the problem
to ISCP SQL serialization.

Minimal reproduction

set experimental_ivf_index=1;
create database ivf_async_include_bit;
use ivf_async_include_bit;

create table t(
  id bigint primary key,
  flags bit(8),
  v vecf32(2)
);

insert into t
select result,
       b'00100111', -- 0x27, ASCII single quote
       cast(concat('[',result,',0]') as vecf32(2))
from generate_series(1,10) g;

create index ix using ivfflat on t(v)
  lists=1
  op_type 'vector_l2_ops'
  quantization 'float16'
  include(flags)
  async;

After waiting well beyond the time needed by safe controls:

select count(*) from <ix entries table>;
-- 0 (expected 10)

The same result occurs with b'01011100' (0x5c, backslash).

Reproduction matrix

INCLUDE value async entries synchronous entries
BIT(8) 0x27 0 / 10 10 / 10
BIT(8) 0x5c 0 / 10 10 / 10
BIT(8) 0x00 10 / 10 10 / 10
BIT(8) 0x01 10 / 10 10 / 10
BIT(8) 0xff 10 / 10 10 / 10

Three independently created async databases containing 0x27 remained at zero
entries. Safe controls created at the same time reached 10 entries in about 14
seconds.

After ALTER TABLE ... ALTER REINDEX ... FORCE_SYNC, the affected index contains
all 10 rows and stores HEX(flags) = '27'. Inserting another source row with
0x27 then leaves the entries table at 10 rows and the new primary key absent,
confirming that ongoing async maintenance is affected as well as initial replay.

Root cause

pkg/iscp/util.go:convertColIntoSql serializes BIT by putting its raw bytes
between single quotes:

sqlBuff = appendByte(sqlBuff, '\'')
sqlBuff = appendBytes(sqlBuff, b)
sqlBuff = appendByte(sqlBuff, '\'')

Unlike string handling, this branch does not escape quote or backslash bytes;
unlike BINARY/VARBINARY/BLOB, it does not use a hex literal. The generated
ISCP SQL is therefore syntactically invalid or changes escape interpretation for
these valid BIT values.

Expected behavior

Every valid BIT value must be copied byte-for-byte into the IVFFLAT entries
table during initial async replay and later INSERT/UPDATE operations. BIT should
be serialized with a binary-safe literal representation.

Regression coverage

  • all 256 BIT(8) values, especially 0x00, 0x27, 0x5c, and 0xff;
  • widths that are not a multiple of eight;
  • one and multiple BIT INCLUDE columns;
  • initial replay plus later INSERT/UPDATE;
  • synchronous build control;
  • generated ISCP SQL must use a binary-safe representation.

Activity

  1. added
    kind/bug
    on Sep 16, 2026
  2. added this to the MO-202609 milestone on Sep 16, 2026
  3. added theissue type on Sep 16, 2026
  4. added
    ai-easy
    on Oct 12, 2026
  5. Ariznawlll commented on Oct 13, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main;commit:175a645a85994f2c95992d3aa8d6dacb6d9e167f;2026-10-13。
    • 环境:本地隔离 MatrixOne 服务;按用例使用真实 SQL、MySQL 二进制协议或异步索引。

    原问题验证

    异步 IVFFLAT INCLUDE(BIT) 初始 0x27(引号字节),更新为 0x5C(反斜杠字节)并插入新行后,hidden entries 的 HEX 值与源表一致。 对应定向用例在 MOTR 入口重复执行 3 次均通过(每次脚本内再执行 3 轮)。

    Happy Path 覆盖

    初始 BIT 索引条目完整。

    Unhappy Path 覆盖

    特殊字节不再导致转义或列值错误,CDC 行数和投影正确。

    白盒验证

    除 SQL 返回值外,读取系统索引元数据与 hidden entries,并以源表作为独立判定基准。

    回归测试

    MOTR PR #234 中的 issue_29012_29013_29015_29016_29019_29053_ivf.py 已提交;离线 CI 通过,仍待正常 review/merge。该缺陷由确定性语义/类型/协议边界触发,不需要另加 big-data 或 chaos 才能验收。

    测试证据

    PR 验证记录及 CI 运行。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

4.3-devai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions