mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
LRUCache fix exception unsafe element insertion
This commit is contained in:
parent
f1223e7548
commit
31b7734407
@ -271,16 +271,23 @@ private:
|
||||
|
||||
void setImpl(const Key & key, const MappedPtr & mapped, [[maybe_unused]] std::lock_guard<std::mutex> & cache_lock)
|
||||
{
|
||||
auto res = cells.emplace(std::piecewise_construct,
|
||||
auto [it, inserted] = cells.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(key),
|
||||
std::forward_as_tuple());
|
||||
|
||||
Cell & cell = res.first->second;
|
||||
bool inserted = res.second;
|
||||
Cell & cell = it->second;
|
||||
|
||||
if (inserted)
|
||||
{
|
||||
cell.queue_iterator = queue.insert(queue.end(), key);
|
||||
try
|
||||
{
|
||||
cell.queue_iterator = queue.insert(queue.end(), key);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cells.erase(it);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user