This commit is contained in:
kssenii 2023-04-13 18:53:16 +02:00
parent 461477dabf
commit 599a02ca0d
6 changed files with 7 additions and 11 deletions

View File

@ -26,6 +26,7 @@
#include <Common/TLDListsHolder.h>
#include <Common/quoteString.h>
#include <Common/randomSeed.h>
#include <Common/ThreadPool.h>
#include <Loggers/Loggers.h>
#include <IO/ReadBufferFromFile.h>
#include <IO/ReadBufferFromString.h>

View File

@ -15,6 +15,7 @@
#include <Disks/ObjectStorages/DiskObjectStorageRemoteMetadataRestoreHelper.h>
#include <Disks/ObjectStorages/DiskObjectStorageTransaction.h>
#include <Disks/FakeDiskTransaction.h>
#include <Common/ThreadPool.h>
#include <Poco/Util/AbstractConfiguration.h>
#include <Interpreters/Context.h>

View File

@ -664,6 +664,7 @@ bool FileCache::tryReserve(FileSegment & file_segment, size_t size)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cache became inconsistent. There must be a bug");
file_segment.getKeyMetadata()->createBaseDirectory();
file_segment.reserved_size += size;
return true;
}

View File

@ -380,7 +380,7 @@ FileSegment::State FileSegment::wait(size_t offset)
chassert(!getDownloaderUnlocked(lock).empty());
chassert(!isDownloaderUnlocked(lock));
[[maybe_unused]] auto ok = cv.wait_for(lock, std::chrono::seconds(60), [&, this]()
[[maybe_unused]] const auto ok = cv.wait_for(lock, std::chrono::seconds(60), [&, this]()
{
return download_state != State::DOWNLOADING || offset < getCurrentWriteOffset(true);
});
@ -467,14 +467,6 @@ bool FileSegment::reserve(size_t size_to_reserve)
segment_range.right = range().left + expected_downloaded_size + size_to_reserve;
reserved = cache->tryReserve(*this, size_to_reserve);
if (reserved)
{
/// No lock is required because reserved size is always
/// mananaged (read/modified) by the downloader only
/// or in isLastOwnerOfFileSegment() case.
/// It is made atomic because of getInfoForLog.
reserved_size += size_to_reserve;
}
chassert(assertCorrectness());
}

View File

@ -64,6 +64,7 @@ struct CreateFileSegmentSettings
class FileSegment : private boost::noncopyable, public std::enable_shared_from_this<FileSegment>
{
friend struct LockedKey;
friend class FileCache; /// Because of reserved_size in tryReserve().
public:
using Key = FileCacheKey;

View File

@ -113,8 +113,8 @@ void LRUFileCachePriority::iterate(IterateFunc && func, const CacheGuard::Lock &
{
throw Exception(
ErrorCodes::LOGICAL_ERROR,
"Mismatch of file segment size in file segment metadata and priority queue: {} != {}",
it->size, metadata->size());
"Mismatch of file segment size in file segment metadata and priority queue: {} != {} ({})",
it->size, metadata->size(), metadata->file_segment->getInfoForLog());
}
auto result = func(*locked_key, metadata);