Fix LazyMaterializingTransform lazy chunk mismatch with vector search rescoring#111003
Conversation
… rescoring Lazy materialization built its lazy read from ReadFromMergeTree::getParts(), copying the parts together with the use_vector_search_result_filter read hint set for vector_search_with_rescoring=1. The lazy read then re-applied the vector index candidate filter on top of the rows it already selected by global row index. When several distances tie, the vector index candidate set can differ from the rows the LIMIT kept, so the extra filter dropped a selected row and the lazy chunk ended up shorter than the offsets, tripping a LOGICAL_ERROR in prepareLazyChunk. Clear use_vector_search_result_filter on the parts handed to the lazy read: it must re-fetch exactly the rows the main read selected and must not re-filter by vector candidates. The main read keeps the hint and behaves as before. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-0:20260719-142200 |
Internal second-model review — adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 full pass + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-author-slot-0:20260719-142200 |
|
cc @novikd @shankar-iyer — could you review this? It fixes a |
|
Workflow [PR], commit [3d0f860] Summary: ✅
AI ReviewSummaryThis PR fixes the lazy-materialization/vector-search rescoring interaction by clearing Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 8/8 (100.00%) · Uncovered code |
CI finish ledger — 3d0f860Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens.
This PR's own diff (LazyMaterializingTransform vector-rescoring fix in optimizeLazyMaterialization.cpp + one vector-search test) is unrelated to all three failures; none is PR-caused. Session id: cron:our-pr-ci-monitor:20260719-230000 |
6bf231c
Pulls in the fix for the unrelated stress-test failure `LazyMaterializingTransform: Number of rows in lazy chunk A does not match number of offsets B` (fixed on master by #111003).
Related: #97223
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
LOGICAL_ERROR(LazyMaterializingTransform: Number of rows in lazy chunk N does not match number of offsets M) that could happen for vector search queries withvector_search_with_rescoring = 1combined with lazy materialization when several distances tie.Description
Lazy materialization builds its lazy read from
ReadFromMergeTree::getParts(), which copies the parts together with theuse_vector_search_result_filterread hint that vector search rescoring sets on them. The lazy read then re-applied the vector index candidate filter on top of the rows it had already selected by global row index. When several distances tie, the vector index candidate set can differ from the rows theLIMITkept, so the extra filter dropped a selected row and the lazy chunk ended up shorter than the offsets, tripping the assertion inprepareLazyChunk.The lazy read must re-fetch exactly the rows the main read selected and must not re-filter by vector candidates, so
use_vector_search_result_filteris cleared on the parts handed to the lazy read. The main read keeps the hint and is unchanged.Reproducer (STID 4770-4443, found by the AST fuzzer, e.g. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108846&sha=0d5e67f1a19eeb4051f2ca77cf8033c9547f5187&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%29):
Version info
26.7.1.1203(included in26.7and later)