```
2020.09.15 03:58:54.128255 [ 67248 ] {} <Fatal> BaseDaemon: ########################################
2020.09.15 03:58:54.136857 [ 67248 ] {} <Fatal> BaseDaemon: (version 20.10.1.4646, build id: 4188F711D6A01AE1) (from thread 5295) (no query) Received signal Segmentation fault (11)
2020.09.15 03:58:54.138488 [ 67248 ] {} <Fatal> BaseDaemon: Address: 0x14008 Access: write. Address not mapped to object.
2020.09.15 03:58:54.139559 [ 67248 ] {} <Fatal> BaseDaemon: Stack trace: 0x272c5afd 0x272c5673 0x272c4b7e 0x2732b6da 0x27290247 0x2728dc59 0x272960cc 0xf13b135 0xf146acc 0xf1468fd 0xf1332ea 0xf14011c 0x7fdc2e14e669 0x7fdc2e0652b3
2020.09.15 03:58:54.207851 [ 67248 ] {} <Fatal> BaseDaemon: 4. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/__hash_table:2412: std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > > > >::__rehash(unsigned long) @ 0x272c5afd in /usr/bin/clickhouse
2020.09.15 03:58:54.217151 [ 67248 ] {} <Fatal> BaseDaemon: 5. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/__hash_table:0: std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > > > >::rehash(unsigned long) @ 0x272c5673 in /usr/bin/clickhouse
2020.09.15 03:58:54.226430 [ 67248 ] {} <Fatal> BaseDaemon: 6. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/__hash_table:0: std::__1::pair<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, void*>*>, bool> std::__1::__hash_table<std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::__unordered_map_hasher<unsigned long, std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::hash<unsigned long>, true>, std::__1::__unordered_map_equal<unsigned long, std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, std::__1::equal_to<unsigned long>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned long, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > > > >::__emplace_unique_key_args<unsigned long, std::__1::piecewise_construct_t const&, std::__1::tuple<unsigned long const&>, std::__1::tuple<> >(unsigned long const&, std::__1::piecewise_construct_t const&, std::__1::tuple<unsigned long const&>&&, std::__1::tuple<>&&) @ 0x272c4b7e in /usr/bin/clickhouse
2020.09.15 03:58:54.262730 [ 67248 ] {} <Fatal> BaseDaemon: 7. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/vector:1516: std::__1::__function::__func<void DB::CacheDictionary::getItemsNumberImpl<unsigned long, unsigned long, DB::CacheDictionary::getUInt64(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul>&) const::$_3>(DB::CacheDictionary::Attribute&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> const&, std::__1::conditional<IsDecimalNumber<unsigned long>, DB::DecimalPaddedPODArray<unsigned long>, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> >::type&, DB::CacheDictionary::getUInt64(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul>&) const::$_3&&) const::'lambda'(unsigned long, unsigned long), std::__1::allocator<void DB::CacheDictionary::getItemsNumberImpl<unsigned long, unsigned long, DB::CacheDictionary::getUInt64(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul>&) const::$_3>(DB::CacheDictionary::Attribute&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> const&, std::__1::conditional<IsDecimalNumber<unsigned long>, DB::DecimalPaddedPODArray<unsigned long>, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> >::type&, DB::CacheDictionary::getUInt64(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul> const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 15ul, 16ul>&) const::$_3&&) const::'lambda'(unsigned long, unsigned long)>, void (unsigned long, unsigned long)>::operator()(unsigned long&&, unsigned long&&) @ 0x2732b6da in /usr/bin/clickhouse
2020.09.15 03:58:54.267629 [ 67248 ] {} <Fatal> BaseDaemon: 8. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1825: DB::CacheDictionary::update(std::__1::shared_ptr<DB::CacheDictionary::UpdateUnit>&) const @ 0x27290247 in /usr/bin/clickhouse
2020.09.15 03:58:54.271302 [ 67248 ] {} <Fatal> BaseDaemon: 9. /build/obj-x86_64-linux-gnu/../src/Dictionaries/CacheDictionary.cpp:0: DB::CacheDictionary::updateThreadFunction() @ 0x2728dc59 in /usr/bin/clickhouse
2020.09.15 03:58:54.275174 [ 67248 ] {} <Fatal> BaseDaemon: 10. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1714: std::__1::__function::__func<DB::CacheDictionary::CacheDictionary(DB::StorageID const&, DB::DictionaryStructure const&, std::__1::unique_ptr<DB::IDictionarySource, std::__1::default_delete<DB::IDictionarySource> >, DB::ExternalLoadableLifetime, unsigned long, unsigned long, bool, unsigned long, unsigned long, unsigned long, unsigned long)::$_4, std::__1::allocator<DB::CacheDictionary::CacheDictionary(DB::StorageID const&, DB::DictionaryStructure const&, std::__1::unique_ptr<DB::IDictionarySource, std::__1::default_delete<DB::IDictionarySource> >, DB::ExternalLoadableLifetime, unsigned long, unsigned long, bool, unsigned long, unsigned long, unsigned long, unsigned long)::$_4>, void ()>::operator()() @ 0x272960cc in /usr/bin/clickhouse
2020.09.15 03:58:54.275927 [ 67248 ] {} <Fatal> BaseDaemon: 11. /build/obj-x86_64-linux-gnu/../src/Common/CurrentMetrics.h:74: ThreadPoolImpl<ThreadFromGlobalPool>::worker(std::__1::__list_iterator<ThreadFromGlobalPool, void*>) @ 0xf13b135 in /usr/bin/clickhouse
2020.09.15 03:58:54.277034 [ 67248 ] {} <Fatal> BaseDaemon: 12. /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:172: ThreadFromGlobalPool::ThreadFromGlobalPool<void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()>(void&&, void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()&&...)::'lambda'()::operator()() const @ 0xf146acc in /usr/bin/clickhouse
2020.09.15 03:58:54.278371 [ 67248 ] {} <Fatal> BaseDaemon: 13. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1714: std::__1::__function::__func<ThreadFromGlobalPool::ThreadFromGlobalPool<void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()>(void&&, void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()&&...)::'lambda'(), std::__1::allocator<ThreadFromGlobalPool::ThreadFromGlobalPool<void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()>(void&&, void ThreadPoolImpl<ThreadFromGlobalPool>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()&&...)::'lambda'()>, void ()>::operator()() @ 0xf1468fd in /usr/bin/clickhouse
2020.09.15 03:58:54.278744 [ 67248 ] {} <Fatal> BaseDaemon: 14. /build/obj-x86_64-linux-gnu/../src/Common/CurrentMetrics.h:74: ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xf1332ea in /usr/bin/clickhouse
2020.09.15 03:58:54.287852 [ 67248 ] {} <Fatal> BaseDaemon: 15. /build/obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2615: void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda1'()> >(void*) @ 0xf14011c in /usr/bin/clickhouse
2020.09.15 03:58:54.288061 [ 67248 ] {} <Fatal> BaseDaemon: 16. start_thread @ 0x9669 in /usr/lib/x86_64-linux-gnu/libpthread-2.30.so
2020.09.15 03:58:54.288168 [ 67248 ] {} <Fatal> BaseDaemon: 17. clone @ 0x1222b3 in /usr/lib/x86_64-linux-gnu/libc-2.30.so
```

https://clickhouse-test-reports.s3.yandex.net/14628/da6beb1a91950c45bbc462eff263451dd5a594fb/stress_test_(memory).html

cc: @nikitamikhaylov 

#pragma once
#include <atomic>
#include <chrono>
#include <cmath>
#include <map>
#include <mutex>
#include <shared_mutex>
#include <utility>
#include <variant>
#include <vector>
#include <common/logger_useful.h>
#include <Columns/ColumnDecimal.h>
#include <Columns/ColumnString.h>