mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 09:38:39 +08:00
fix:expand lock range for dump_snapshot (#44130)
issue: #44129 Signed-off-by: luzhang <luzhang@zilliz.com> Co-authored-by: luzhang <luzhang@zilliz.com>
This commit is contained in:
parent
7721edf32a
commit
e2f34d7b78
@ -105,7 +105,15 @@ class DeletedRecord {
|
||||
|
||||
bool can_dump = timestamps[0] >= max_load_timestamp_;
|
||||
if (can_dump) {
|
||||
auto start_time = std::chrono::steady_clock::now();
|
||||
DumpSnapshot();
|
||||
auto end_time = std::chrono::steady_clock::now();
|
||||
auto duration =
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
end_time - start_time);
|
||||
LOG_INFO("dump delete record snapshot cost: {}ms for segment: {}",
|
||||
duration.count() / 1000,
|
||||
segment_id_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,11 +241,11 @@ class DeletedRecord {
|
||||
|
||||
void
|
||||
DumpSnapshot() {
|
||||
std::unique_lock<std::shared_mutex> lock(snap_lock_);
|
||||
SortedDeleteList::Accessor accessor(deleted_lists_);
|
||||
int total_size = accessor.size();
|
||||
int dumped_size = dumped_entry_count_.load();
|
||||
|
||||
while (total_size - dumped_size > DUMP_BATCH_SIZE) {
|
||||
while (total_size - dumped_entry_count_.load() > DUMP_BATCH_SIZE) {
|
||||
int32_t bitsize = 0;
|
||||
if constexpr (is_sealed) {
|
||||
bitsize = sealed_row_count_;
|
||||
@ -255,7 +263,7 @@ class DeletedRecord {
|
||||
snapshots_.back().second.size());
|
||||
}
|
||||
|
||||
while (total_size - dumped_size > DUMP_BATCH_SIZE &&
|
||||
while (total_size - dumped_entry_count_.load() > DUMP_BATCH_SIZE &&
|
||||
it != accessor.end()) {
|
||||
Timestamp dump_ts = 0;
|
||||
|
||||
@ -266,8 +274,6 @@ class DeletedRecord {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(snap_lock_);
|
||||
if (dump_ts == last_dump_ts) {
|
||||
// only update
|
||||
snapshots_.back().second = std::move(bitmap.clone());
|
||||
@ -280,21 +286,18 @@ class DeletedRecord {
|
||||
snap_next_iter_.push_back(it);
|
||||
}
|
||||
|
||||
dumped_entry_count_.store(dumped_size + DUMP_BATCH_SIZE);
|
||||
dumped_entry_count_.fetch_add(DUMP_BATCH_SIZE);
|
||||
LOG_INFO(
|
||||
"dump delete record snapshot at ts: {}, cursor: {}, "
|
||||
"total size:{} "
|
||||
"current snapshot size: {} for segment: {}",
|
||||
dump_ts,
|
||||
dumped_size + DUMP_BATCH_SIZE,
|
||||
dumped_entry_count_.load(),
|
||||
total_size,
|
||||
snapshots_.size(),
|
||||
segment_id_);
|
||||
last_dump_ts = dump_ts;
|
||||
}
|
||||
|
||||
dumped_size += DUMP_BATCH_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user