@@ -17,8 +17,7 @@ std::optional<Entry> HashTablesStatistics<Entry>::getSizeHint(const Params & par
1717 if (!params.isCollectionAndUseEnabled ())
1818 throw DB::Exception (DB::ErrorCodes::LOGICAL_ERROR, " Collection and use of the statistics should be enabled." );
1919
20- std::lock_guard lock (mutex);
21- const auto cache = getHashTableStatsCache (params, lock);
20+ const auto cache = getHashTableStatsCache (params);
2221 if (const auto hint = cache->get (params.key ))
2322 {
2423 LOG_TRACE (getLogger (" HashTablesStatistics" ), " An entry for key={} found in cache: {}" , params.key , hint->dump ());
@@ -34,8 +33,7 @@ void HashTablesStatistics<Entry>::update(const Entry & new_entry, const Params &
3433 if (!params.isCollectionAndUseEnabled ())
3534 throw DB::Exception (DB::ErrorCodes::LOGICAL_ERROR, " Collection and use of the statistics should be enabled." );
3635
37- std::lock_guard lock (mutex);
38- const auto cache = getHashTableStatsCache (params, lock);
36+ const auto cache = getHashTableStatsCache (params);
3937 const auto hint = cache->get (params.key );
4038 // We'll maintain the maximum among all the observed values until another prediction is much lower (that should indicate some change)
4139 if (!hint || hint->shouldBeUpdated (new_entry))
@@ -60,9 +58,9 @@ std::optional<HashTablesCacheStatistics> HashTablesStatistics<Entry>::getCacheSt
6058}
6159
6260template <typename Entry>
63- HashTablesStatistics<Entry>::CachePtr
64- HashTablesStatistics<Entry>::getHashTableStatsCache(const Params & params, const std::lock_guard<std::mutex> &)
61+ HashTablesStatistics<Entry>::CachePtr HashTablesStatistics<Entry>::getHashTableStatsCache(const Params & params)
6562{
63+ std::lock_guard lock (mutex);
6664 if (!hash_table_stats)
6765 hash_table_stats = std::make_shared<Cache>(params.max_entries_for_hash_table_stats * sizeof (Entry));
6866 return hash_table_stats;
0 commit comments