Skip to content

fix: join job may cause inconsistent delta indices#5328

Merged
wjones127 merged 9 commits intolance-format:mainfrom
BubbleCal:spfresh-join
Nov 24, 2025
Merged

fix: join job may cause inconsistent delta indices#5328
wjones127 merged 9 commits intolance-format:mainfrom
BubbleCal:spfresh-join

Conversation

@BubbleCal
Copy link
Copy Markdown
Contributor

@BubbleCal BubbleCal commented Nov 24, 2025

fix #5312

  • handle the case of delta indices have diff number of partitions, split/join will merge all delta indices into one
  • trigger join on incremental indexing, not remap

Signed-off-by: BubbleCal <bubble-cal@outlook.com>
@github-actions github-actions Bot added the bug Something isn't working label Nov 24, 2025
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
@BubbleCal BubbleCal requested a review from wjones127 November 24, 2025 11:24
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
Signed-off-by: BubbleCal <bubble-cal@outlook.com>

pub fn partition_size(&self, part: usize) -> usize {
self.lengths[part] as usize
self.lengths.get(part).copied().unwrap_or_default() as usize
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will return a zero in the previous case that panicked. Is that a correct fix? Seems like zero would be an incorrect or unexpected result. What's the consequence of a zero return value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this gets the size of the given partition, say delta index A has 3 partitions and delta index B has 4 partitions, when we calculate the total partition size of 4-th partition, index A just returns 0, and this is correct because we can consider that index A has 4 partitions but the 4-th is empty.

and after the fix, we will merge all delta indices into one, so the unwrap_or_default() path will never be reached

) -> Result<Option<Box<dyn RecordBatchStream + Unpin + 'static>>> {
if partition_id >= self.partition_sizes.len() {
return Ok(None);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar question here - is it a cause for concern that this function would be asked for an out of bounds partition? If so should this be an error?

"partition index is {} but the number of partitions is {}, skip loading it",
part_idx,
index.ivf_model().num_partitions()
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it correct to think we'll see this in some cases initially but should not see it in the long term?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is just for fixing the corrupted delta indices, after merging them, we will never reach these branches

Copy link
Copy Markdown
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good. I agree we should avoid doing partition joins in remaps; that seems like the job of optimize indices.

There's some minor naming changes that I think could improve readability, but these are existing issues anyways.

Comment thread rust/lance/src/index/vector/builder.rs Outdated
Comment thread rust/lance/src/index/vector/builder.rs
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 93.26425% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance/src/index/vector/builder.rs 82.97% 13 Missing and 3 partials ⚠️
rust/lance/src/index/vector/ivf/v2.rs 96.52% 9 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: BubbleCal <bubble-cal@outlook.com>
@wjones127 wjones127 merged commit e26d0e1 into lance-format:main Nov 24, 2025
40 of 43 checks passed
jackye1995 pushed a commit to jackye1995/lance that referenced this pull request Jan 21, 2026
fix lance-format#5312 

- handle the case of delta indices have diff number of partitions,
split/join will merge all delta indices into one
- trigger join on incremental indexing, not remap

---------

Signed-off-by: BubbleCal <bubble-cal@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic while optimizing vector indices

3 participants