mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 03:12:43 +00:00
Release the lock earlier
This commit is contained in:
parent
bf1174d5af
commit
b6c3694369
@ -676,8 +676,9 @@ bool FileCache::tryReserveImpl(
|
||||
if (is_overflow())
|
||||
return false;
|
||||
|
||||
for (auto & [_, current_locked_key] : locked)
|
||||
for (auto it = locked.begin(); it != locked.end();)
|
||||
{
|
||||
auto & current_locked_key = it->second;
|
||||
for (const auto & offset_to_delete : current_locked_key->delete_offsets)
|
||||
{
|
||||
auto * file_segment_metadata = current_locked_key->getKeyMetadata().getByOffset(offset_to_delete);
|
||||
@ -685,6 +686,9 @@ bool FileCache::tryReserveImpl(
|
||||
if (query_context)
|
||||
query_context->remove(key, offset);
|
||||
}
|
||||
|
||||
/// Do not hold the key lock longer than required.
|
||||
it = locked.erase(it);
|
||||
}
|
||||
|
||||
if (file_segment_for_reserve)
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
const bool recache_on_query_limit_exceeded;
|
||||
};
|
||||
|
||||
/// CacheGuard::Lock protects all priority queues.
|
||||
class LockedQueryContext
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user