Skip to content

[Bug]: INT8 IVFFLAT distance-only range drops rows while equivalent membership query succeeds #29536

Closed

Description

@XuPeng-SH

Branch / commit / environment

Actual / expected behavior

A distance-only range over an INT8 IVFFLAT index returns no rows for a fixture whose scalar L2 distances are 2.5, 1, and 0. The predicate 1.5 < distance < 3 should select id 101. Adding the ordinary predicate grp=1, which is true for every fixture row, makes the indexed query return id 101. Both plans use Vector Index Scan.

Only l2_distance is used, including cache warming. No switch to l2_distance_sq is necessary, so this is separate from the stale cached function units in #29038. F32/F64 and BF16 controls passed during the associated QA; the INT8 distance-only branch is the confirmed failing cell. Broader types/modes are not claimed affected.

Minimal reproduction

set experimental_ivf_index=1;
set ivf_preload_entries=0;
set probe_limit=1;
drop database if exists ivf_int8_range_repro;
create database ivf_int8_range_repro;
use ivf_int8_range_repro;
create table t(id int primary key, grp int, label varchar(20), v vecf32(1));
insert into t values (101,1,'edge','[2.5]'),(102,1,'near','[1]'),(103,1,'zero','[0]');
create index idx using ivfflat on t(v) lists=1 op_type 'vector_l2_ops'
include(grp,label) quantization 'int8';
set @entries=(select distinct i.index_table_name from mo_catalog.mo_indexes i
 join mo_catalog.mo_tables t on i.table_id=t.rel_id
 where t.reldatabase=database() and t.relname='t' and i.name='idx'
 and i.algo_table_type='entries');
select mo_ctl('dn','flush',concat(database(),'.',@entries));
-- Baseline diagnostic also asserts table_stats refresh/full reports persisted objects.
select id from t order by l2_distance(v,'[0]') limit 20 by rank with option 'mode=post';

-- Actual: empty. Expected: id 101.
select id,grp,label from t
where l2_distance(v,'[0]') > 1.5 and l2_distance(v,'[0]') < 3
order by l2_distance(v,'[0]') limit 10 by rank with option 'mode=post';

-- Scalar reference: id 101.
select id,grp,label from t
where l2_distance(v,'[0]') > 1.5 and l2_distance(v,'[0]') < 3 order by id;

-- Indexed control: id 101; grp=1 holds for every row.
select id,grp,label from t
where grp=1 and l2_distance(v,'[0]') > 1.5 and l2_distance(v,'[0]') < 3
order by l2_distance(v,'[0]') limit 10 by rank with option 'mode=post';
drop database ivf_int8_range_repro;

Evidence and investigation boundary

The clean-base MySQL diagnostic asserts persisted object presence and Vector Index Scan. It fails with expected []int{101}, actual []int(nil). The control retaining grp=1 passes on the same baseline; the distance-only failure also occurs on the candidate. Each diagnostic cleans up its database and isolated cluster.

The exact code cause is not yet established. Investigate where the distance-only planner/search route consumes or transports the source-unit range versus the membership/INCLUDE route, including affine query encoding and exact filtering before Top-K. Preserve the existing quantization and range owners; avoid compensating with a per-example branch or materializing wide embeddings. A correction should make ordinary predicate removal preserve results, then verify both source and squared distance units, cold/warm cache, persisted/memory entries and bounded candidate behavior with small independent fixtures.

Activity

  1. self-assigned this
    on Sep 30, 2026
  2. added a commit that references this issue on Oct 1, 2026
    112f7f3
  3. Ariznawlll commented on Oct 2, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • Commit:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 部署方式:本地全新单 CN mo-service,独立数据目录;MySQL 文本协议与 server-side PREPARE
    • 测试日期:2026-10-02

    原问题验证

    按 issue 原始语义在上述 commit 重新执行并重复 3 次。IVFFLAT distance-only 与 membership 组合查询均返回 id 101。

    Happy Path 覆盖

    覆盖索引路径、全表对照和不同 LIMIT。

    Unhappy Path 覆盖

    覆盖空集合、NULL vector 与不命中 predicate;无漏页/错页。

    白盒验证

    关联修复 #29535 已进入当前 main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。

    回归测试

    测试证据

    • 精确测试版本:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 当前结果:IVFFLAT distance-only 与 membership 组合查询均返回 id 101。
    • 回归代码与 golden result 已提交到 MOTR #209;本地全量 14_issue_regression 中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions