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() { ~DeletedRecord() {
if constexpr (is_sealed) { if constexpr (is_sealed) {
cachinglayer::Manager::GetInstance().RefundLoadedResource( if (estimated_memory_size_ > 0) {
{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 bool
contain(const PkType& pk) const { contain(const PkType& pk) const {
return pk2offset_->contain(pk); return pk2offset_->contain(pk);
@ -587,9 +595,11 @@ class InsertRecordSealed {
timestamp_index_ = TimestampIndex(); timestamp_index_ = TimestampIndex();
pk2offset_->clear(); pk2offset_->clear();
reserved = 0; reserved = 0;
cachinglayer::Manager::GetInstance().RefundLoadedResource( if (estimated_memory_size_ > 0) {
{static_cast<int64_t>(estimated_memory_size_), 0}); cachinglayer::Manager::GetInstance().RefundLoadedResource(
estimated_memory_size_ = 0; {static_cast<int64_t>(estimated_memory_size_), 0});
estimated_memory_size_ = 0;
}
} }
public: public: