Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:fix delete record assert failed #38580

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/core/src/index/TextMatchIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ TextMatchIndex::MatchQuery(const std::string& query) {
Reload();
}

// The count opeartion of tantivy may be get older cnt if the index is committed with new tantivy segment.
// So we cannot use the count operation to get the total count for bitmap.
// Just use the maximum offset of hits to get the total count for bitmap here.
auto hits = wrapper_->match_query(query);
auto cnt = should_allocate_bitset_size(hits);
TargetBitmap bitset(cnt);
Expand Down
16 changes: 10 additions & 6 deletions internal/core/src/segcore/DeletedRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@ class DeletedRecord {
return;
}

InternalPush(pks, timestamps);
auto max_deleted_ts = InternalPush(pks, timestamps);

SortedDeleteList::Accessor accessor(deleted_lists_);
auto* last = accessor.last();
Assert(last != nullptr);
max_load_timestamp_ = last->first;
if (max_deleted_ts > max_load_timestamp_) {
max_load_timestamp_ = max_deleted_ts;
}

//TODO: add support for dump snapshot when load finished
}
Expand All @@ -106,15 +105,19 @@ class DeletedRecord {
}
}

void
Timestamp
InternalPush(const std::vector<PkType>& pks, const Timestamp* timestamps) {
int64_t removed_num = 0;
int64_t mem_add = 0;
Timestamp max_timestamp = 0;

SortedDeleteList::Accessor accessor(deleted_lists_);
for (size_t i = 0; i < pks.size(); ++i) {
auto deleted_pk = pks[i];
auto deleted_ts = timestamps[i];
if (deleted_ts > max_timestamp) {
max_timestamp = deleted_ts;
}
std::vector<SegOffset> offsets;
if (segment_) {
offsets =
Expand Down Expand Up @@ -151,6 +154,7 @@ class DeletedRecord {

n_.fetch_add(removed_num);
mem_size_.fetch_add(mem_add);
return max_timestamp;
}

void
Expand Down
Loading