mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-13 02:53:38 +00:00
fix race in operations with external temporary data in cache
This commit is contained in:
parent
bd17ee769e
commit
27d632f5e4
@ -352,7 +352,10 @@ CacheMetadata::removeEmptyKey(
|
||||
try
|
||||
{
|
||||
if (fs::exists(key_directory))
|
||||
{
|
||||
fs::remove_all(key_directory);
|
||||
LOG_TEST(log, "Directory ({}) for key {} removed", key_directory.string(), key);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -365,7 +368,10 @@ CacheMetadata::removeEmptyKey(
|
||||
{
|
||||
std::unique_lock mutex(key_prefix_directory_mutex);
|
||||
if (fs::exists(key_prefix_directory) && fs::is_empty(key_prefix_directory))
|
||||
{
|
||||
fs::remove(key_prefix_directory);
|
||||
LOG_TEST(log, "Prefix directory ({}) for key {} removed", key_prefix_directory.string(), key);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -106,7 +106,10 @@ FileSegmentsHolderPtr TemporaryDataOnDisk::createCacheFile(size_t max_file_size)
|
||||
|
||||
const auto key = FileSegment::Key::random();
|
||||
auto holder = file_cache->set(key, 0, std::max(10_MiB, max_file_size), CreateFileSegmentSettings(FileSegmentKind::Temporary, /* unbounded */ true));
|
||||
fs::create_directories(file_cache->getPathInLocalCache(key));
|
||||
|
||||
chassert(holder->size() == 1);
|
||||
holder->back().getKeyMetadata()->createBaseDirectory();
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user