Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched recent issues for IVF/threshold/panic, index out of range, Shrink, and the exact filterEntryDistanceRange symbol. #29040 concerns distance-boundary semantics, #29038 concerns cached distance-function identity, and #27757 concerns connection failures. None accurately tracks this empty-column batch compaction panic.
Branch Name
main
Commit ID
7ce783464806490263c184f22aaf5d307225adef
Other Environment Information
- Main Weekly run 36089256712, IVF job 107976971342.
- Workflow revision:
152893c2e851e45db1ef2146060ba1afa7f123e9, profileweekly-shadow-1x2. - Namespace:
mo-main-family-36089256712-1; 1 TP CN + 2 AP CN + 1 TN. - CN memory limit 55 GiB, FileService memory cache 16 GiB, GOMEMLIMIT 25000 MiB.
- Wiki 10M, VECF32(768), IVFFLAT L2, lists=3162, probe_limit=5, ivf_preload_entries=0, k=10, concurrency=100, 10000 requests per round.
- SQL entered through AP
nightly-regression-dis-ap-cn-4l2k5; the recovered pipeline panic was logged on remote APnightly-regression-dis-ap-cn-xfk5l.
Actual Behavior
During the first l2_filter_threshold / mode=post round, the job recorded 240 failed queries. 239 were backend-create/connection failures tracked separately under #27757; one was an independent recovered MO execution panic. They must not all be classified as network errors.
The target AP logged the panic at 2026-09-25 08:08:45.180257 UTC / 16:08:45.180257 CST. The coordinating AP returned it to SQL at 08:08:45.568541 UTC:
internal error: panic runtime error: index out of range [0] with length 0
vector.shrinkFixed vector.go:10101
(*Vector).Shrink vector.go:6076
(*Batch).Shrink batch.go:1687
(*IvfflatSearchIndex).filterEntryDistanceRange
relation_search.go:583
(*IvfflatSearchIndex).scanEntriesInDomain.func1
relation_search.go:226
(*relationScanner).ScanRelation plan_reader.go:865
...
(*Pipeline).Run
Correlation identifiers:
- Statement:
01a0d79c-1372-7521-aa89-99bf8fb4a29e - Transaction:
22955069869267a218d872fb8b06e044 - Trace:
720f92e6-e9d5-f82c-20ed-7c62aa81541c
All nine cluster pods had zero restart-count increases over the checked IVF window. This is a recovered query-level panic, not evidence that the CN process crashed or that stored data was corrupted.
Expected Behavior
A valid distance-threshold query must filter the selected rows without attempting to shrink a deliberately unmaterialized embedding column. Correct SQL execution must not depend on whether a storage Top-K batch passes the exact distance range wholly or only partially.
Steps to Reproduce
The observed workload has this SQL shape (the runtime statement log truncates the long query vector, so this is a parameterized shape, not a standalone copy of the exact failing vector):
SELECT file_id, id, l2_distance(embedding, ?) AS dist
FROM historical_file_blocks_wiki_ivfflat10m
WHERE file_id = ? AND l2_distance(embedding, ?) <= 2.5
ORDER BY dist ASC
LIMIT 10 BY RANK WITH OPTION 'mode=post';- Prepare the Wiki 10M IVFFLAT index using the linked job configuration.
- Run its existing
l2_filter_threshold / postworkload at concurrency 100. - Inspect query errors individually rather than combining the non-connection panic with the backend timeouts.
The full TKE workload was not rerun in this investigation. A narrow local batch-contract reproducer at the exact deployed SHA did reproduce the same panic deterministically:
Go 1.26.4, darwin/arm64, repository CGo test wrapper
TestDistanceRangeFiltersStorageTopNBatchWithEmptyEntry
FAIL: index out of range [0] with length 0
filterEntryDistanceRange -> Batch.Shrink -> Vector.Shrink -> shrinkFixed
The local test obtains two scores with the real objectio.TopNVector, constructs the documented storage Top-K output layout (materialized scalar columns and distance column, empty typed entry column), and applies a distance range that retains only the first row. It uses a small VECF64 fixture to exercise the common batch contract; it does not claim to reproduce the original 768-dimensional input or the separate TCP timeouts. Test code and output are preserved in the investigation evidence bundle.
Additional information
Concrete code-level contract violation
- Persisted Top-K intentionally does not materialize the high-width embedding column after calculating scores.
materializeVectorTopNRowsskipstopColPos, then callsoutputBat.Vecs[topColPos].CleanOnlyData()while returning row-aligned scalar columns and appended distances. The exact-membership path has the same empty-slot contract. scanEntriesInDomain's BatchTransform recognizes storage-provided distances and callsfilterEntryDistanceRangeon that batch. The typed-empty embedding is legal at this boundary, not malformed client data.- The partial-survivor branch uses
bat.Shrink(sels, false)whenever0 < len(sels) < bat.RowCount(). Batch.Shrinkshrinks every column, including the zero-length entry slot.shrinkFixed[types.Varlena]indexes that empty slot and panics. The all-survive and none-survive branches avoid this call, explaining why many queries succeed.
The runtime stack and local contract reproduction identify the unsafe compaction operation. The exact original candidate values that made the final range retain only a subset are not preserved in the truncated SQL log; conservative storage bounds followed by exact source-domain filtering are a legitimate reason for such a subset.
Main status and evidence boundaries
- Latest main checked:
ce7f84dabc563fa5bb29c648e8b02aa6581b608b. The production functions above are unchanged from the deployed SHA; no subsequent fix was found in that comparison. - A recent pass of [Bug]: IVFFLAT l2_distance range predicates use a different boundary value than scalar evaluation #29040's small boundary fixture does not cover this persisted Top-K empty-slot interaction. This report does not claim the original [Bug]: IVFFLAT l2_distance range predicates use a different boundary value than scalar evaluation #29040 wrong-result fix was ineffective.
- No introducing commit is assigned without a controlled historical reproduction.
- The slow successful PRE rounds and the 265 total connection failures in the same job are separate findings, not consequences proven to originate from this panic.
Activity
slyunnn commentedon Sep 28, 2026
Additional main evidence: stable query-level 20101 in Wiki threshold/post
This is additional correlation evidence, not a claim that the exact panic stack in this issue has already been captured again.
main@9b7c2c23dba737232d975d66bd04628199e1a436e2ccdf8b980fe70d2efc3b0d587d3b3309a235b4VECF32(768), IVFFlat L2,lists=3162,quantization=bf16,probe_limit=5,ivf_preload_entries=0l2_filter_threshold,mode=post,k=10, 10,000 queries/round, concurrency 100, upper distance bound 2.5.All three post-filter rounds completed their accounting but each recorded the same two query-level failures:
The corresponding
l2_filter_threshold + mode=prerounds completed with zero failures. The job preserved the client receipt and workflow logs, but this run did not retain the server-side error string/stack for these two query IDs. Therefore this evidence should be triaged against the existingfilterEntryDistanceRange/empty-slot panic here, rather than asserted as a confirmed duplicate of its root cause.fix(ivfflat): preserve sparse batches and distance semantics (#29535)
slyunnn commentedon Oct 8, 2026
Regression and extended verification for #29381 (2026-10-08)
Verification Environment
origin/main:8929ab4946fbc7d44b6757fe5b12de6c74118c21—fix(sql): preserve DECIMAL pruning for prepared integer comparisons (#29667).112f7f396351ff34b63af8b66e15f6d1a39befde; the directly relevant change is0dfe50bd6508335ad2dd459d44357f4706254c9f(fix(ivfflat): preserve unloaded entries during distance filtering).mo-servicebuilt from that exactmaincommit:2 CN / 1 TN / 1 Log service / Proxy.mainand commit8929ab4946fbc7d44b6757fe5b12de6c74118c21. Client protocol was the MySQL text protocol through the MySQL CLI.What Was Covered
l2_distance(v, [1,1,1]) <= 1.73205077returned onlyid = 1through Proxy, with no20101panic.id = 1; subsequent reads remained healthy.<= 1.7320508returned1,2, while<= 1.73205077returned1; this exercises the widened storage candidate followed by exact filtering path.< 5returned1,2through the IVFFLAT index.5,NULL, then1; results were1,2, empty, then1without connection or service failure.EXPLAINshowedVector Index Scanand noTable Scanfor the indexable distance predicate.TestCompactRelationTopBoundsRowsWithClearedEntryVector,TestDistanceRangeFiltersBeforeTopInSourceUnits, andTestRelationSearchBoundaryBranches.10Mworkload reproduction. A large-data rerun is not required: the defect depends on an unloaded embedding slot plus a partial survivor during storage Top-K compaction, not row count, block or batch size, memory or spill, concurrency, skew, network transfer, or resource scale. The persisted4-row boundary case is the minimal stable execution boundary.Findings
The fix preserves sparse batch layout while compacting scalar and distance columns after exact distance filtering. All three MySQL endpoints completed the original partial-survivor regression without a panic, and the service stayed healthy afterwards. No
20101,index out of range, or actual panic signature was observed in the isolated service logs.MOTR / BVT Coverage
Existing BVT coverage is present in
test/distributed/cases/vector/vector_ivf_prepare_dist_range.sql, including the#29381persisted-entry narrow-boundary query and its expected result. Existing targeted unit coverage directly asserts that a cleared embedding vector entry remains valid while the result batch is compacted. No MOTR change is needed because the existing product BVT and unit cases already cover the regression contract; no test source was modified.Final Conclusion
Fixed. The repair is in current
main, and real MySQL-protocol regression on the fresh2 CN / 1 TN / 1 Log service / Proxytopology passed through Proxy, CN1, and CN2. Large-data regression is not required for this issue because scale is not a causal dimension of the sparse-batch compaction bug.