Repository navigation
Description
Branch / commit / environment
main,c2abd6a54b7cd3e13c1b1494388cd7a81b8369d4.- Darwin arm64, Go 1.26.4, CPU native build, isolated local CN/TN/LogService.
- Three rows, IVFFLAT lists=1, persisted entries,
ivf_preload_entries=0. - Independently encountered while validating [Bug]: IVFFLAT cache keeps the first L2 function and misfilters later l2/l2sq ranges #29038 in fix(ivfflat): preserve sparse batches and distance semantics #29535. Reproduced on clean baseline production source; it is not introduced by either fix in fix(ivfflat): preserve sparse batches and distance semantics #29535.
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
fix(ivfflat): preserve sparse batches and distance semantics (#29535)
Ariznawlll commentedon Oct 2, 2026
测试版本
maind50a2d475a406829f67127fef7b2ad4abc1c1d3dmo-service,独立数据目录;MySQL 文本协议与 server-side PREPARE原问题验证
按 issue 原始语义在上述 commit 重新执行并重复 3 次。IVFFLAT distance-only 与 membership 组合查询均返回 id 101。
Happy Path 覆盖
覆盖索引路径、全表对照和不同 LIMIT。
Unhappy Path 覆盖
覆盖空集合、NULL vector 与不命中 predicate;无漏页/错页。
白盒验证
关联修复 #29535 已进入当前
main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。回归测试
suites/14_issue_regression/t/issue_recent_vector_contracts.test714/714条语句通过。测试证据
d50a2d475a406829f67127fef7b2ad4abc1c1d3d14_issue_regression中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。测试结论
测试通过。