From 15bb127b0127ae260c9ca23e25aadb2ff1839e20 Mon Sep 17 00:00:00 2001 From: serxa Date: Fri, 6 Jan 2023 23:35:38 +0000 Subject: [PATCH] replace every `std::shared_mutex` with `DB::FastSharedMutex` --- src/Common/ProfilingScopedRWLock.h | 10 +++--- src/Common/ThreadStatus.h | 2 +- src/Common/Threading.h | 6 ++-- src/Dictionaries/CacheDictionary.h | 4 +-- src/Dictionaries/CacheDictionaryUpdateQueue.h | 2 +- .../FakeMetadataStorageFromDisk.h | 2 +- .../MetadataStorageFromDisk.cpp | 4 +-- .../ObjectStorages/MetadataStorageFromDisk.h | 6 ++-- ...taStorageFromDiskTransactionOperations.cpp | 30 ++++++++--------- ...dataStorageFromDiskTransactionOperations.h | 32 +++++++++---------- src/Interpreters/DatabaseCatalog.cpp | 4 +-- src/Interpreters/DatabaseCatalog.h | 10 +++--- src/Interpreters/GraceHashJoin.h | 3 +- src/Interpreters/InterserverIOHandler.h | 4 +-- src/Interpreters/MergeJoin.h | 5 ++- src/Interpreters/ProcessList.h | 2 +- src/Interpreters/Set.cpp | 2 +- src/Interpreters/Set.h | 4 +-- src/Storages/IStorage.h | 2 +- src/Storages/MergeTree/IMergeTreeDataPart.h | 5 ++- src/Storages/MergeTree/MergeTreeData.h | 2 +- .../RocksDB/StorageEmbeddedRocksDB.cpp | 6 ++-- src/Storages/RocksDB/StorageEmbeddedRocksDB.h | 4 +-- src/Storages/StorageFile.h | 2 +- src/Storages/StorageLog.h | 3 +- src/Storages/StorageStripeLog.h | 2 +- src/Storages/WindowView/StorageWindowView.cpp | 4 +-- src/Storages/WindowView/StorageWindowView.h | 2 +- 28 files changed, 81 insertions(+), 83 deletions(-) diff --git a/src/Common/ProfilingScopedRWLock.h b/src/Common/ProfilingScopedRWLock.h index f5753f9ce46..70f4d607d56 100644 --- a/src/Common/ProfilingScopedRWLock.h +++ b/src/Common/ProfilingScopedRWLock.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -12,7 +12,7 @@ class ProfilingScopedWriteRWLock { public: - ProfilingScopedWriteRWLock(std::shared_mutex & rwl_, ProfileEvents::Event event) : + ProfilingScopedWriteRWLock(DB::FastSharedMutex & rwl_, ProfileEvents::Event event) : scoped_write_lock(rwl_) { ProfileEvents::increment(event, watch.elapsed()); @@ -20,14 +20,14 @@ public: private: Stopwatch watch; - std::unique_lock scoped_write_lock; + std::unique_lock scoped_write_lock; }; class ProfilingScopedReadRWLock { public: - ProfilingScopedReadRWLock(std::shared_mutex & rwl, ProfileEvents::Event event) : + ProfilingScopedReadRWLock(DB::FastSharedMutex & rwl, ProfileEvents::Event event) : scoped_read_lock(rwl) { ProfileEvents::increment(event, watch.elapsed()); @@ -35,7 +35,7 @@ public: private: Stopwatch watch; - std::shared_lock scoped_read_lock; + std::shared_lock scoped_read_lock; }; } diff --git a/src/Common/ThreadStatus.h b/src/Common/ThreadStatus.h index cbcd8c3c30a..eaef57785e6 100644 --- a/src/Common/ThreadStatus.h +++ b/src/Common/ThreadStatus.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -14,7 +15,6 @@ #include #include #include -#include #include diff --git a/src/Common/Threading.h b/src/Common/Threading.h index 7a656b05ff1..55db2359532 100644 --- a/src/Common/Threading.h +++ b/src/Common/Threading.h @@ -3,7 +3,9 @@ #include #include -#include +#include // for chassert to work + +#include // for std::shared_lock and std::unique_lock #ifdef OS_LINUX /// Because of futex @@ -216,8 +218,6 @@ private: #else -#include - // WARNING: We support cancellable synchronization primitives only on linux for now namespace DB diff --git a/src/Dictionaries/CacheDictionary.h b/src/Dictionaries/CacheDictionary.h index d4716999b47..fe9e585fe3e 100644 --- a/src/Dictionaries/CacheDictionary.h +++ b/src/Dictionaries/CacheDictionary.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -14,6 +13,7 @@ #include #include +#include #include #include @@ -206,7 +206,7 @@ private: /// This lock is used for the inner cache state update function lock it for /// write, when it need to update cache state all other functions just /// readers. Surprisingly this lock is also used for last_exception pointer. - mutable std::shared_mutex rw_lock; + mutable DB::FastSharedMutex rw_lock; mutable std::exception_ptr last_exception; mutable std::atomic error_count {0}; diff --git a/src/Dictionaries/CacheDictionaryUpdateQueue.h b/src/Dictionaries/CacheDictionaryUpdateQueue.h index 8db5c4a59df..3b19de71d85 100644 --- a/src/Dictionaries/CacheDictionaryUpdateQueue.h +++ b/src/Dictionaries/CacheDictionaryUpdateQueue.h @@ -2,12 +2,12 @@ #include #include -#include #include #include #include #include +#include #include #include #include diff --git a/src/Disks/ObjectStorages/FakeMetadataStorageFromDisk.h b/src/Disks/ObjectStorages/FakeMetadataStorageFromDisk.h index 849e7235c0a..7abcbabcc49 100644 --- a/src/Disks/ObjectStorages/FakeMetadataStorageFromDisk.h +++ b/src/Disks/ObjectStorages/FakeMetadataStorageFromDisk.h @@ -15,7 +15,7 @@ class FakeMetadataStorageFromDisk final : public IMetadataStorage private: friend class FakeMetadataStorageFromDiskTransaction; - mutable std::shared_mutex metadata_mutex; + mutable DB::FastSharedMutex metadata_mutex; DiskPtr disk; ObjectStoragePtr object_storage; diff --git a/src/Disks/ObjectStorages/MetadataStorageFromDisk.cpp b/src/Disks/ObjectStorages/MetadataStorageFromDisk.cpp index 625350eeeff..69fb4b8888c 100644 --- a/src/Disks/ObjectStorages/MetadataStorageFromDisk.cpp +++ b/src/Disks/ObjectStorages/MetadataStorageFromDisk.cpp @@ -83,7 +83,7 @@ std::string MetadataStorageFromDisk::readInlineDataToString(const std::string & return readMetadata(path)->getInlineData(); } -DiskObjectStorageMetadataPtr MetadataStorageFromDisk::readMetadataUnlocked(const std::string & path, std::shared_lock &) const +DiskObjectStorageMetadataPtr MetadataStorageFromDisk::readMetadataUnlocked(const std::string & path, std::shared_lock &) const { auto metadata = std::make_unique(disk->getPath(), object_storage_root_path, path); auto str = readFileToString(path); @@ -91,7 +91,7 @@ DiskObjectStorageMetadataPtr MetadataStorageFromDisk::readMetadataUnlocked(const return metadata; } -DiskObjectStorageMetadataPtr MetadataStorageFromDisk::readMetadataUnlocked(const std::string & path, std::unique_lock &) const +DiskObjectStorageMetadataPtr MetadataStorageFromDisk::readMetadataUnlocked(const std::string & path, std::unique_lock &) const { auto metadata = std::make_unique(disk->getPath(), object_storage_root_path, path); auto str = readFileToString(path); diff --git a/src/Disks/ObjectStorages/MetadataStorageFromDisk.h b/src/Disks/ObjectStorages/MetadataStorageFromDisk.h index 2c80572e7b4..f3a662fc566 100644 --- a/src/Disks/ObjectStorages/MetadataStorageFromDisk.h +++ b/src/Disks/ObjectStorages/MetadataStorageFromDisk.h @@ -17,7 +17,7 @@ class MetadataStorageFromDisk final : public IMetadataStorage private: friend class MetadataStorageFromDiskTransaction; - mutable std::shared_mutex metadata_mutex; + mutable DB::FastSharedMutex metadata_mutex; DiskPtr disk; std::string object_storage_root_path; @@ -67,8 +67,8 @@ public: DiskObjectStorageMetadataPtr readMetadata(const std::string & path) const; - DiskObjectStorageMetadataPtr readMetadataUnlocked(const std::string & path, std::unique_lock & lock) const; - DiskObjectStorageMetadataPtr readMetadataUnlocked(const std::string & path, std::shared_lock & lock) const; + DiskObjectStorageMetadataPtr readMetadataUnlocked(const std::string & path, std::unique_lock & lock) const; + DiskObjectStorageMetadataPtr readMetadataUnlocked(const std::string & path, std::shared_lock & lock) const; }; class MetadataStorageFromDiskTransaction final : public IMetadataTransaction diff --git a/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.cpp b/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.cpp index ce5171fedee..fb5ae2668e6 100644 --- a/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.cpp +++ b/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.cpp @@ -26,7 +26,7 @@ SetLastModifiedOperation::SetLastModifiedOperation(const std::string & path_, Po { } -void SetLastModifiedOperation::execute(std::unique_lock &) +void SetLastModifiedOperation::execute(std::unique_lock &) { old_timestamp = disk.getLastModified(path); disk.setLastModified(path, new_timestamp); @@ -44,7 +44,7 @@ ChmodOperation::ChmodOperation(const std::string & path_, mode_t mode_, IDisk & { } -void ChmodOperation::execute(std::unique_lock &) +void ChmodOperation::execute(std::unique_lock &) { old_mode = disk.stat(path).st_mode; disk.chmod(path, mode); @@ -61,7 +61,7 @@ UnlinkFileOperation::UnlinkFileOperation(const std::string & path_, IDisk & disk { } -void UnlinkFileOperation::execute(std::unique_lock &) +void UnlinkFileOperation::execute(std::unique_lock &) { auto buf = disk.readFile(path, ReadSettings{}, std::nullopt, disk.getFileSize(path)); readStringUntilEOF(prev_data, *buf); @@ -81,7 +81,7 @@ CreateDirectoryOperation::CreateDirectoryOperation(const std::string & path_, ID { } -void CreateDirectoryOperation::execute(std::unique_lock &) +void CreateDirectoryOperation::execute(std::unique_lock &) { disk.createDirectory(path); } @@ -97,7 +97,7 @@ CreateDirectoryRecursiveOperation::CreateDirectoryRecursiveOperation(const std:: { } -void CreateDirectoryRecursiveOperation::execute(std::unique_lock &) +void CreateDirectoryRecursiveOperation::execute(std::unique_lock &) { namespace fs = std::filesystem; fs::path p(path); @@ -124,7 +124,7 @@ RemoveDirectoryOperation::RemoveDirectoryOperation(const std::string & path_, ID { } -void RemoveDirectoryOperation::execute(std::unique_lock &) +void RemoveDirectoryOperation::execute(std::unique_lock &) { disk.removeDirectory(path); } @@ -141,7 +141,7 @@ RemoveRecursiveOperation::RemoveRecursiveOperation(const std::string & path_, ID { } -void RemoveRecursiveOperation::execute(std::unique_lock &) +void RemoveRecursiveOperation::execute(std::unique_lock &) { if (disk.isFile(path)) disk.moveFile(path, temp_path); @@ -174,7 +174,7 @@ CreateHardlinkOperation::CreateHardlinkOperation(const std::string & path_from_, { } -void CreateHardlinkOperation::execute(std::unique_lock & lock) +void CreateHardlinkOperation::execute(std::unique_lock & lock) { auto metadata = metadata_storage.readMetadataUnlocked(path_from, lock); @@ -201,7 +201,7 @@ MoveFileOperation::MoveFileOperation(const std::string & path_from_, const std:: { } -void MoveFileOperation::execute(std::unique_lock &) +void MoveFileOperation::execute(std::unique_lock &) { disk.moveFile(path_from, path_to); } @@ -218,7 +218,7 @@ MoveDirectoryOperation::MoveDirectoryOperation(const std::string & path_from_, c { } -void MoveDirectoryOperation::execute(std::unique_lock &) +void MoveDirectoryOperation::execute(std::unique_lock &) { disk.moveDirectory(path_from, path_to); } @@ -236,7 +236,7 @@ ReplaceFileOperation::ReplaceFileOperation(const std::string & path_from_, const { } -void ReplaceFileOperation::execute(std::unique_lock &) +void ReplaceFileOperation::execute(std::unique_lock &) { if (disk.exists(path_to)) disk.moveFile(path_to, temp_path_to); @@ -262,7 +262,7 @@ WriteFileOperation::WriteFileOperation(const std::string & path_, IDisk & disk_, { } -void WriteFileOperation::execute(std::unique_lock &) +void WriteFileOperation::execute(std::unique_lock &) { if (disk.exists(path)) { @@ -288,7 +288,7 @@ void WriteFileOperation::undo() } } -void AddBlobOperation::execute(std::unique_lock & metadata_lock) +void AddBlobOperation::execute(std::unique_lock & metadata_lock) { DiskObjectStorageMetadataPtr metadata; if (metadata_storage.exists(path)) @@ -309,7 +309,7 @@ void AddBlobOperation::undo() write_operation->undo(); } -void UnlinkMetadataFileOperation::execute(std::unique_lock & metadata_lock) +void UnlinkMetadataFileOperation::execute(std::unique_lock & metadata_lock) { auto metadata = metadata_storage.readMetadataUnlocked(path, metadata_lock); uint32_t ref_count = metadata->getRefCount(); @@ -336,7 +336,7 @@ void UnlinkMetadataFileOperation::undo() write_operation->undo(); } -void SetReadonlyFileOperation::execute(std::unique_lock & metadata_lock) +void SetReadonlyFileOperation::execute(std::unique_lock & metadata_lock) { auto metadata = metadata_storage.readMetadataUnlocked(path, metadata_lock); metadata->setReadOnly(); diff --git a/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.h b/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.h index 0bce6141301..ad026880c22 100644 --- a/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.h +++ b/src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.h @@ -13,7 +13,7 @@ class IDisk; struct IMetadataOperation { - virtual void execute(std::unique_lock & metadata_lock) = 0; + virtual void execute(std::unique_lock & metadata_lock) = 0; virtual void undo() = 0; virtual void finalize() {} virtual ~IMetadataOperation() = default; @@ -26,7 +26,7 @@ struct SetLastModifiedOperation final : public IMetadataOperation { SetLastModifiedOperation(const std::string & path_, Poco::Timestamp new_timestamp_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -41,7 +41,7 @@ struct ChmodOperation final : public IMetadataOperation { ChmodOperation(const std::string & path_, mode_t mode_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -57,7 +57,7 @@ struct UnlinkFileOperation final : public IMetadataOperation { UnlinkFileOperation(const std::string & path_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -72,7 +72,7 @@ struct CreateDirectoryOperation final : public IMetadataOperation { CreateDirectoryOperation(const std::string & path_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -86,7 +86,7 @@ struct CreateDirectoryRecursiveOperation final : public IMetadataOperation { CreateDirectoryRecursiveOperation(const std::string & path_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -101,7 +101,7 @@ struct RemoveDirectoryOperation final : public IMetadataOperation { RemoveDirectoryOperation(const std::string & path_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -114,7 +114,7 @@ struct RemoveRecursiveOperation final : public IMetadataOperation { RemoveRecursiveOperation(const std::string & path_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -130,7 +130,7 @@ struct WriteFileOperation final : public IMetadataOperation { WriteFileOperation(const std::string & path_, IDisk & disk_, const std::string & data_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; private: @@ -149,7 +149,7 @@ struct CreateHardlinkOperation final : public IMetadataOperation IDisk & disk_, const MetadataStorageFromDisk & metadata_storage_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -166,7 +166,7 @@ struct MoveFileOperation final : public IMetadataOperation { MoveFileOperation(const std::string & path_from_, const std::string & path_to_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -181,7 +181,7 @@ struct MoveDirectoryOperation final : public IMetadataOperation { MoveDirectoryOperation(const std::string & path_from_, const std::string & path_to_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -196,7 +196,7 @@ struct ReplaceFileOperation final : public IMetadataOperation { ReplaceFileOperation(const std::string & path_from_, const std::string & path_to_, IDisk & disk_); - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -226,7 +226,7 @@ struct AddBlobOperation final : public IMetadataOperation , metadata_storage(metadata_storage_) {} - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -254,7 +254,7 @@ struct UnlinkMetadataFileOperation final : public IMetadataOperation { } - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; @@ -279,7 +279,7 @@ struct SetReadonlyFileOperation final : public IMetadataOperation { } - void execute(std::unique_lock & metadata_lock) override; + void execute(std::unique_lock & metadata_lock) override; void undo() override; diff --git a/src/Interpreters/DatabaseCatalog.cpp b/src/Interpreters/DatabaseCatalog.cpp index 6ac01a9473f..0ed9a8dc2ce 100644 --- a/src/Interpreters/DatabaseCatalog.cpp +++ b/src/Interpreters/DatabaseCatalog.cpp @@ -729,7 +729,7 @@ DDLGuardPtr DatabaseCatalog::getDDLGuard(const String & database, const String & return std::make_unique(db_guard.first, db_guard.second, std::move(lock), table, database); } -std::unique_lock DatabaseCatalog::getExclusiveDDLGuardForDatabase(const String & database) +std::unique_lock DatabaseCatalog::getExclusiveDDLGuardForDatabase(const String & database) { DDLGuards::iterator db_guard_iter; { @@ -1282,7 +1282,7 @@ TemporaryLockForUUIDDirectory & TemporaryLockForUUIDDirectory::operator = (Tempo } -DDLGuard::DDLGuard(Map & map_, std::shared_mutex & db_mutex_, std::unique_lock guards_lock_, const String & elem, const String & database_name) +DDLGuard::DDLGuard(Map & map_, DB::FastSharedMutex & db_mutex_, std::unique_lock guards_lock_, const String & elem, const String & database_name) : map(map_), db_mutex(db_mutex_), guards_lock(std::move(guards_lock_)) { it = map.emplace(elem, Entry{std::make_unique(), 0}).first; diff --git a/src/Interpreters/DatabaseCatalog.h b/src/Interpreters/DatabaseCatalog.h index a3fa4515a69..cac8541b437 100644 --- a/src/Interpreters/DatabaseCatalog.h +++ b/src/Interpreters/DatabaseCatalog.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -17,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -58,7 +58,7 @@ public: DDLGuard( Map & map_, - std::shared_mutex & db_mutex_, + DB::FastSharedMutex & db_mutex_, std::unique_lock guards_lock_, const String & elem, const String & database_name); @@ -69,7 +69,7 @@ public: private: Map & map; - std::shared_mutex & db_mutex; + DB::FastSharedMutex & db_mutex; Map::iterator it; std::unique_lock guards_lock; std::unique_lock table_lock; @@ -142,7 +142,7 @@ public: /// Get an object that protects the table from concurrently executing multiple DDL operations. DDLGuardPtr getDDLGuard(const String & database, const String & table); /// Get an object that protects the database from concurrent DDL queries all tables in the database - std::unique_lock getExclusiveDDLGuardForDatabase(const String & database); + std::unique_lock getExclusiveDDLGuardForDatabase(const String & database); void assertDatabaseExists(const String & database_name) const; @@ -298,7 +298,7 @@ private: /// For the duration of the operation, an element is placed here, and an object is returned, /// which deletes the element in the destructor when counter becomes zero. /// In case the element already exists, waits when query will be executed in other thread. See class DDLGuard below. - using DatabaseGuard = std::pair; + using DatabaseGuard = std::pair; using DDLGuards = std::map; DDLGuards ddl_guards TSA_GUARDED_BY(ddl_guards_mutex); /// If you capture mutex and ddl_guards_mutex, then you need to grab them strictly in this order. diff --git a/src/Interpreters/GraceHashJoin.h b/src/Interpreters/GraceHashJoin.h index f4e75f142f3..26506dbc93b 100644 --- a/src/Interpreters/GraceHashJoin.h +++ b/src/Interpreters/GraceHashJoin.h @@ -7,6 +7,7 @@ #include #include +#include #include @@ -130,7 +131,7 @@ private: TemporaryDataOnDiskPtr tmp_data; Buckets buckets; - mutable std::shared_mutex rehash_mutex; + mutable DB::FastSharedMutex rehash_mutex; FileBucket * current_bucket = nullptr; mutable std::mutex current_bucket_mutex; diff --git a/src/Interpreters/InterserverIOHandler.h b/src/Interpreters/InterserverIOHandler.h index 69b742db2ec..3f21f23766a 100644 --- a/src/Interpreters/InterserverIOHandler.h +++ b/src/Interpreters/InterserverIOHandler.h @@ -7,11 +7,11 @@ #include #include #include +#include #include #include #include -#include #include namespace zkutil @@ -43,7 +43,7 @@ public: /// You need to stop the data transfer if blocker is activated. ActionBlocker blocker; - std::shared_mutex rwlock; + DB::FastSharedMutex rwlock; }; using InterserverIOEndpointPtr = std::shared_ptr; diff --git a/src/Interpreters/MergeJoin.h b/src/Interpreters/MergeJoin.h index 770ca0409bf..5be637c1feb 100644 --- a/src/Interpreters/MergeJoin.h +++ b/src/Interpreters/MergeJoin.h @@ -1,7 +1,6 @@ #pragma once -#include - +#include #include #include #include @@ -72,7 +71,7 @@ private: using Cache = CacheBase, BlockByteWeight>; - mutable std::shared_mutex rwlock; + mutable DB::FastSharedMutex rwlock; std::shared_ptr table_join; SizeLimits size_limits; SortDescription left_sort_description; diff --git a/src/Interpreters/ProcessList.h b/src/Interpreters/ProcessList.h index 34edfc5a2e2..8edae5fa866 100644 --- a/src/Interpreters/ProcessList.h +++ b/src/Interpreters/ProcessList.h @@ -19,13 +19,13 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include diff --git a/src/Interpreters/Set.cpp b/src/Interpreters/Set.cpp index e75232aa0f5..87c74766bb1 100644 --- a/src/Interpreters/Set.cpp +++ b/src/Interpreters/Set.cpp @@ -176,7 +176,7 @@ bool Set::insertFromBlock(const ColumnsWithTypeAndName & columns) bool Set::insertFromBlock(const Columns & columns) { - std::lock_guard lock(rwlock); + std::lock_guard lock(rwlock); if (data.empty()) throw Exception("Method Set::setHeader must be called before Set::insertFromBlock", ErrorCodes::LOGICAL_ERROR); diff --git a/src/Interpreters/Set.h b/src/Interpreters/Set.h index bafb0dcea7a..d11ab109df5 100644 --- a/src/Interpreters/Set.h +++ b/src/Interpreters/Set.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -8,6 +7,7 @@ #include #include +#include #include @@ -131,7 +131,7 @@ private: /** Protects work with the set in the functions `insertFromBlock` and `execute`. * These functions can be called simultaneously from different threads only when using StorageSet, */ - mutable std::shared_mutex rwlock; + mutable DB::FastSharedMutex rwlock; template void insertFromBlockImpl( diff --git a/src/Storages/IStorage.h b/src/Storages/IStorage.h index 2c4ea91869c..3292244dc3b 100644 --- a/src/Storages/IStorage.h +++ b/src/Storages/IStorage.h @@ -17,9 +17,9 @@ #include #include #include +#include #include -#include #include diff --git a/src/Storages/MergeTree/IMergeTreeDataPart.h b/src/Storages/MergeTree/IMergeTreeDataPart.h index 2c5169a1729..bf8ded9bbaa 100644 --- a/src/Storages/MergeTree/IMergeTreeDataPart.h +++ b/src/Storages/MergeTree/IMergeTreeDataPart.h @@ -1,6 +1,7 @@ #pragma once -#include "IO/WriteSettings.h" +#include +#include #include #include #include @@ -22,8 +23,6 @@ #include #include -#include - namespace zkutil { diff --git a/src/Storages/MergeTree/MergeTreeData.h b/src/Storages/MergeTree/MergeTreeData.h index 670c755cf72..caf778667ee 100644 --- a/src/Storages/MergeTree/MergeTreeData.h +++ b/src/Storages/MergeTree/MergeTreeData.h @@ -1086,7 +1086,7 @@ protected: MultiVersion storage_settings; /// Used to determine which UUIDs to send to root query executor for deduplication. - mutable std::shared_mutex pinned_part_uuids_mutex; + mutable DB::FastSharedMutex pinned_part_uuids_mutex; PinnedPartUUIDsPtr pinned_part_uuids; /// True if at least one part was created/removed with transaction. diff --git a/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp b/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp index 2fcedf550e8..130b0bfd128 100644 --- a/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp +++ b/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,6 @@ #include #include -#include #include @@ -491,7 +491,7 @@ static StoragePtr create(const StorageFactory::Arguments & args) std::shared_ptr StorageEmbeddedRocksDB::getRocksDBStatistics() const { - std::shared_lock lock(rocksdb_ptr_mx); + std::shared_lock lock(rocksdb_ptr_mx); if (!rocksdb_ptr) return nullptr; return rocksdb_ptr->GetOptions().statistics; @@ -499,7 +499,7 @@ std::shared_ptr StorageEmbeddedRocksDB::getRocksDBStatistic std::vector StorageEmbeddedRocksDB::multiGet(const std::vector & slices_keys, std::vector & values) const { - std::shared_lock lock(rocksdb_ptr_mx); + std::shared_lock lock(rocksdb_ptr_mx); if (!rocksdb_ptr) return {}; return rocksdb_ptr->MultiGet(rocksdb::ReadOptions(), slices_keys, &values); diff --git a/src/Storages/RocksDB/StorageEmbeddedRocksDB.h b/src/Storages/RocksDB/StorageEmbeddedRocksDB.h index eec817acd55..830910d3e42 100644 --- a/src/Storages/RocksDB/StorageEmbeddedRocksDB.h +++ b/src/Storages/RocksDB/StorageEmbeddedRocksDB.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include @@ -86,7 +86,7 @@ private: const String primary_key; using RocksDBPtr = std::unique_ptr; RocksDBPtr rocksdb_ptr; - mutable std::shared_mutex rocksdb_ptr_mx; + mutable DB::FastSharedMutex rocksdb_ptr_mx; String rocksdb_dir; Int32 ttl; bool read_only; diff --git a/src/Storages/StorageFile.h b/src/Storages/StorageFile.h index 03b3aacb67f..3eff78510f1 100644 --- a/src/Storages/StorageFile.h +++ b/src/Storages/StorageFile.h @@ -3,10 +3,10 @@ #include #include +#include #include #include -#include namespace DB diff --git a/src/Storages/StorageLog.h b/src/Storages/StorageLog.h index a2b1356f240..27edad8da2f 100644 --- a/src/Storages/StorageLog.h +++ b/src/Storages/StorageLog.h @@ -1,15 +1,14 @@ #pragma once #include -#include #include #include #include +#include #include #include - namespace DB { diff --git a/src/Storages/StorageStripeLog.h b/src/Storages/StorageStripeLog.h index 3f1b4ed0ad5..8682c16328a 100644 --- a/src/Storages/StorageStripeLog.h +++ b/src/Storages/StorageStripeLog.h @@ -1,11 +1,11 @@ #pragma once #include -#include #include #include #include +#include #include #include #include diff --git a/src/Storages/WindowView/StorageWindowView.cpp b/src/Storages/WindowView/StorageWindowView.cpp index 442a7822e33..baf0d517fb8 100644 --- a/src/Storages/WindowView/StorageWindowView.cpp +++ b/src/Storages/WindowView/StorageWindowView.cpp @@ -1443,11 +1443,11 @@ void StorageWindowView::writeIntoWindowView( }); } - std::shared_lock fire_signal_lock; + std::shared_lock fire_signal_lock; QueryPipelineBuilder builder; if (window_view.is_proctime) { - fire_signal_lock = std::shared_lock(window_view.fire_signal_mutex); + fire_signal_lock = std::shared_lock(window_view.fire_signal_mutex); /// Fill ____timestamp column with current time in case of now() time column. if (window_view.is_time_column_func_now) diff --git a/src/Storages/WindowView/StorageWindowView.h b/src/Storages/WindowView/StorageWindowView.h index 6da34389e4d..77d48b98e7b 100644 --- a/src/Storages/WindowView/StorageWindowView.h +++ b/src/Storages/WindowView/StorageWindowView.h @@ -213,7 +213,7 @@ private: /// Mutex for the blocks and ready condition std::mutex mutex; - std::shared_mutex fire_signal_mutex; + DB::FastSharedMutex fire_signal_mutex; mutable std::mutex sample_block_lock; /// Mutex to protect access to sample block IntervalKind::Kind window_kind;