Skip to content

Commit

Permalink
fix:fix delete record assert failed (#38580)
Browse files Browse the repository at this point in the history
#38472

Signed-off-by: luzhang <[email protected]>
Co-authored-by: luzhang <[email protected]>
  • Loading branch information
zhagnlu and luzhang authored Dec 19, 2024
1 parent 3d360c0 commit 8fcb33c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
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

0 comments on commit 8fcb33c

Please sign in to comment.