fix: refund loaded resource usage in Insert/DeleteRecord destructor (#44555)

issue: #44528

Signed-off-by: Shawn Wang <shawn.wang@zilliz.com>
This commit is contained in:
sparknack 2025-09-24 16:16:04 +08:00 committed by GitHub
parent eac16a577c
commit 0145dc8c06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 5 deletions

View File

@ -67,8 +67,11 @@ class DeletedRecord {
~DeletedRecord() {
if constexpr (is_sealed) {
cachinglayer::Manager::GetInstance().RefundLoadedResource(
{estimated_memory_size_, 0});
if (estimated_memory_size_ > 0) {
cachinglayer::Manager::GetInstance().RefundLoadedResource(
{estimated_memory_size_, 0});
estimated_memory_size_ = 0;
}
}
}

View File

@ -461,6 +461,14 @@ class InsertRecordSealed {
}
}
~InsertRecordSealed() {
if (estimated_memory_size_ > 0) {
cachinglayer::Manager::GetInstance().RefundLoadedResource(
{static_cast<int64_t>(estimated_memory_size_), 0});
estimated_memory_size_ = 0;
}
}
bool
contain(const PkType& pk) const {
return pk2offset_->contain(pk);
@ -587,9 +595,11 @@ class InsertRecordSealed {
timestamp_index_ = TimestampIndex();
pk2offset_->clear();
reserved = 0;
cachinglayer::Manager::GetInstance().RefundLoadedResource(
{static_cast<int64_t>(estimated_memory_size_), 0});
estimated_memory_size_ = 0;
if (estimated_memory_size_ > 0) {
cachinglayer::Manager::GetInstance().RefundLoadedResource(
{static_cast<int64_t>(estimated_memory_size_), 0});
estimated_memory_size_ = 0;
}
}
public: