Skip to content

Memory leak on PeerPessimisticLocks #18799

@overvenus

Description

@overvenus

Bug Report

PeerPessimisticLocks is a per-peer data structure that does not release its hash map's memory allocation when items are removed. This leads to a memory leak during bulk insert, delete, or update transactions issued sequentially to regions.

pub fn remove(&mut self, key: &Key) {
if let Some((lock, _)) = self.map.remove(key) {
let desc = key.len() + lock.memory_size();
self.memory_size -= desc;
GLOBAL_MEM_SIZE.sub(desc as i64);
}
}

A heap profile shows that the accumulated memory allocation from PeerPessimisticLockss is around 8.56 GiB.

Image

What version of TiKV are you using?

v7.5.6

What operating system and CPU are you using?

Steps to reproduce

Issue bulk insert, delete, or update transactions sequentially to regions.

What did you expect?

No memory leak.

What did happened?

Memory leak.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.report/customerCustomers have encountered this bug.severity/majorsig/transactionSIG: Transactiontype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions