Merge pull request #38601 from kitaisreal/dictionaries-added-tsa-annotations

Dictionaries added TSA annotations
This commit is contained in:
Maksim Kita 2022-06-30 12:51:54 +02:00 committed by GitHub
commit 83375465eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 19 deletions

View File

@ -190,7 +190,7 @@ private:
/// Dictionary source should be used with mutex
mutable std::mutex source_mutex;
mutable DictionarySourcePtr source_ptr;
mutable DictionarySourcePtr source_ptr TSA_GUARDED_BY(source_mutex);
CacheDictionaryStoragePtr cache_storage_ptr;
mutable CacheDictionaryUpdateQueue<dictionary_key_type> update_queue;

View File

@ -194,12 +194,8 @@ QueryPipeline CassandraDictionarySource::loadUpdatedAll()
CassSessionShared CassandraDictionarySource::getSession()
{
/// Reuse connection if exists, create new one if not
auto session = maybe_session.lock();
if (session)
return session;
std::lock_guard lock(connect_mutex);
session = maybe_session.lock();
auto session = maybe_session.lock();
if (session)
return session;

View File

@ -82,9 +82,10 @@ private:
Block sample_block;
ExternalQueryBuilder query_builder;
std::mutex connect_mutex;
CassClusterPtr cluster;
CassSessionWeak maybe_session;
std::mutex connect_mutex;
CassSessionWeak maybe_session TSA_GUARDED_BY(connect_mutex);
};
}

View File

@ -62,26 +62,26 @@ public:
std::string getFullName() const
{
std::lock_guard lock{name_mutex};
std::lock_guard lock{mutex};
return dictionary_id.getNameForLogs();
}
StorageID getDictionaryID() const
{
std::lock_guard lock{name_mutex};
std::lock_guard lock{mutex};
return dictionary_id;
}
void updateDictionaryName(const StorageID & new_name) const
{
std::lock_guard lock{name_mutex};
std::lock_guard lock{mutex};
assert(new_name.uuid == dictionary_id.uuid && dictionary_id.uuid != UUIDHelpers::Nil);
dictionary_id = new_name;
}
std::string getLoadableName() const final
{
std::lock_guard lock{name_mutex};
std::lock_guard lock{mutex};
return dictionary_id.getInternalDictionaryName();
}
@ -92,6 +92,8 @@ public:
std::string getDatabaseOrNoDatabaseTag() const
{
std::lock_guard lock{mutex};
if (!dictionary_id.database_name.empty())
return dictionary_id.database_name;
@ -278,22 +280,20 @@ public:
void setDictionaryComment(String new_comment)
{
std::lock_guard lock{name_mutex};
std::lock_guard lock{mutex};
dictionary_comment = std::move(new_comment);
}
String getDictionaryComment() const
{
std::lock_guard lock{name_mutex};
std::lock_guard lock{mutex};
return dictionary_comment;
}
private:
mutable std::mutex name_mutex;
mutable StorageID dictionary_id;
protected:
String dictionary_comment;
mutable std::mutex mutex;
mutable StorageID dictionary_id TSA_GUARDED_BY(mutex);
String dictionary_comment TSA_GUARDED_BY(mutex);
};
}