mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Merge pull request #64803 from ClickHouse/fix-memory-leak-in-slru
Fix memory leak in slru cache policy
This commit is contained in:
commit
f50fbfa411
@ -325,7 +325,7 @@ void SLRUFileCachePriority::downgrade(IteratorPtr iterator, const CachePriorityG
|
||||
candidate_it->getEntry()->toString());
|
||||
}
|
||||
|
||||
const size_t entry_size = candidate_it->entry->size;
|
||||
const size_t entry_size = candidate_it->getEntry()->size;
|
||||
if (!probationary_queue.canFit(entry_size, 1, lock))
|
||||
{
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
@ -483,7 +483,10 @@ SLRUFileCachePriority::SLRUIterator::SLRUIterator(
|
||||
|
||||
SLRUFileCachePriority::EntryPtr SLRUFileCachePriority::SLRUIterator::getEntry() const
|
||||
{
|
||||
return entry;
|
||||
auto entry_ptr = entry.lock();
|
||||
if (!entry_ptr)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Entry pointer expired");
|
||||
return entry_ptr;
|
||||
}
|
||||
|
||||
size_t SLRUFileCachePriority::SLRUIterator::increasePriority(const CachePriorityGuard::Lock & lock)
|
||||
|
@ -125,7 +125,10 @@ private:
|
||||
|
||||
SLRUFileCachePriority * cache_priority;
|
||||
LRUFileCachePriority::LRUIterator lru_iterator;
|
||||
const EntryPtr entry;
|
||||
/// Entry itself is stored by lru_iterator.entry.
|
||||
/// We have it as a separate field to use entry without requiring any lock
|
||||
/// (which will be required if we wanted to get entry from lru_iterator.getEntry()).
|
||||
const std::weak_ptr<Entry> entry;
|
||||
/// Atomic,
|
||||
/// but needed only in order to do FileSegment::getInfo() without any lock,
|
||||
/// which is done for system tables and logging.
|
||||
|
Loading…
Reference in New Issue
Block a user