mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 19:32:07 +00:00
Get rid of download_mutex
This commit is contained in:
parent
e182f163f8
commit
d14f86cfe8
@ -132,10 +132,6 @@ size_t FileSegment::getDownloadedSize() const
|
|||||||
|
|
||||||
size_t FileSegment::getDownloadedSizeUnlocked(const FileSegmentGuard::Lock &) const
|
size_t FileSegment::getDownloadedSizeUnlocked(const FileSegmentGuard::Lock &) const
|
||||||
{
|
{
|
||||||
if (download_state == State::DOWNLOADED)
|
|
||||||
return downloaded_size;
|
|
||||||
|
|
||||||
std::unique_lock download_lock(download_mutex);
|
|
||||||
return downloaded_size;
|
return downloaded_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,8 +353,6 @@ void FileSegment::write(const char * from, size_t size, size_t offset)
|
|||||||
{
|
{
|
||||||
cache_writer->write(from, size);
|
cache_writer->write(from, size);
|
||||||
|
|
||||||
std::unique_lock download_lock(download_mutex);
|
|
||||||
|
|
||||||
cache_writer->next();
|
cache_writer->next();
|
||||||
|
|
||||||
downloaded_size += size;
|
downloaded_size += size;
|
||||||
|
@ -317,7 +317,7 @@ private:
|
|||||||
LocalCacheWriterPtr cache_writer;
|
LocalCacheWriterPtr cache_writer;
|
||||||
|
|
||||||
/// downloaded_size should always be less or equal to reserved_size
|
/// downloaded_size should always be less or equal to reserved_size
|
||||||
size_t downloaded_size = 0;
|
std::atomic<size_t> downloaded_size = 0;
|
||||||
size_t reserved_size = 0;
|
size_t reserved_size = 0;
|
||||||
|
|
||||||
/// global locking order rule:
|
/// global locking order rule:
|
||||||
@ -328,14 +328,6 @@ private:
|
|||||||
LockedKeyCreatorPtr locked_key_creator;
|
LockedKeyCreatorPtr locked_key_creator;
|
||||||
std::condition_variable cv;
|
std::condition_variable cv;
|
||||||
|
|
||||||
/// Protects downloaded_size access with actual write into fs.
|
|
||||||
/// downloaded_size is not protected by download_mutex in methods which
|
|
||||||
/// can never be run in parallel to FileSegment::write() method
|
|
||||||
/// as downloaded_size is updated only in FileSegment::write() method.
|
|
||||||
/// Such methods are identified by isDownloader() check at their start,
|
|
||||||
/// e.g. they are executed strictly by the same thread, sequentially.
|
|
||||||
mutable std::mutex download_mutex;
|
|
||||||
|
|
||||||
Key file_key;
|
Key file_key;
|
||||||
const std::string file_path;
|
const std::string file_path;
|
||||||
FileCache * cache;
|
FileCache * cache;
|
||||||
|
Loading…
Reference in New Issue
Block a user