Merge pull request #62925 from ClickHouse/fix-temporary-data-in-cache-base-directory-creation

Fix temporary data in cache incorrectly processing failure of cache key directory creation
This commit is contained in:
Kseniia Sumarokova 2024-04-26 10:17:45 +00:00 committed by GitHub
commit ce5ea3b05a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View File

@ -118,7 +118,7 @@ LockedKeyPtr KeyMetadata::lockNoStateCheck()
return std::make_unique<LockedKey>(shared_from_this());
}
bool KeyMetadata::createBaseDirectory()
bool KeyMetadata::createBaseDirectory(bool throw_if_failed)
{
if (!created_base_directory.exchange(true))
{
@ -131,7 +131,7 @@ bool KeyMetadata::createBaseDirectory()
{
created_base_directory = false;
if (e.code() == std::errc::no_space_on_device)
if (!throw_if_failed && e.code() == std::errc::no_space_on_device)
{
LOG_TRACE(cache_metadata->log, "Failed to create base directory for key {}, "
"because no space left on device", key);

View File

@ -113,7 +113,7 @@ struct KeyMetadata : private std::map<size_t, FileSegmentMetadataPtr>,
LockedKeyPtr tryLock();
bool createBaseDirectory();
bool createBaseDirectory(bool throw_if_failed = false);
std::string getPath() const;

View File

@ -111,7 +111,7 @@ FileSegmentsHolderPtr TemporaryDataOnDisk::createCacheFile(size_t max_file_size)
CreateFileSegmentSettings(FileSegmentKind::Temporary, /* unbounded */ true), FileCache::getCommonUser());
chassert(holder->size() == 1);
holder->back().getKeyMetadata()->createBaseDirectory();
holder->back().getKeyMetadata()->createBaseDirectory(/* throw_if_failed */true);
return holder;
}