https://s3.amazonaws.com/clickhouse-test-reports/31887/2fb00172a90a72a1b1c78e294ce605c522cf2253/stress_test__thread__actions_.html

```
==================
WARNING: ThreadSanitizer: data race (pid=502)
  Write of size 8 at 0x7b6401921f40 by thread T659:
    #0 pthread_cond_destroy <null> (clickhouse+0x9b9287a)
    #1 std::__1::__libcpp_condvar_destroy(pthread_cond_t*) obj-x86_64-linux-gnu/../contrib/libcxx/include/__threading_support:447:10 (clickhouse+0x1d2871b9)
    #2 std::__1::condition_variable::~condition_variable() obj-x86_64-linux-gnu/../contrib/libcxx/src/condition_variable_destructor.cpp:42:5 (clickhouse+0x1d2871b9)
    #3 DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params) obj-x86_64-linux-gnu/../src/Processors/Formats/Impl/ParallelFormattingOutputFormat.h:89:5 (clickhouse+0x173c2be0)
    #4 void std::__1::allocator<DB::ParallelFormattingOutputFormat>::construct<DB::ParallelFormattingOutputFormat, DB::ParallelFormattingOutputFormat::Params&>(DB::ParallelFormattingOutputFormat*, DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:886:28 (clickhouse+0x173c1efb)
    #5 void std::__1::allocator_traits<std::__1::allocator<DB::ParallelFormattingOutputFormat> >::__construct<DB::ParallelFormattingOutputFormat, DB::ParallelFormattingOutputFormat::Params&>(std::__1::integral_constant<bool, true>, std::__1::allocator<DB::ParallelFormattingOutputFormat>&, DB::ParallelFormattingOutputFormat*, DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:519:21 (clickhouse+0x173c1efb)
    #6 void std::__1::allocator_traits<std::__1::allocator<DB::ParallelFormattingOutputFormat> >::construct<DB::ParallelFormattingOutputFormat, DB::ParallelFormattingOutputFormat::Params&>(std::__1::allocator<DB::ParallelFormattingOutputFormat>&, DB::ParallelFormattingOutputFormat*, DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:481:14 (clickhouse+0x173c1efb)
    #7 std::__1::__shared_ptr_emplace<DB::ParallelFormattingOutputFormat, std::__1::allocator<DB::ParallelFormattingOutputFormat> >::__shared_ptr_emplace<DB::ParallelFormattingOutputFormat::Params&>(std::__1::allocator<DB::ParallelFormattingOutputFormat>, DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2594:9 (clickhouse+0x173c1efb)
    #8 std::__1::shared_ptr<DB::ParallelFormattingOutputFormat> std::__1::allocate_shared<DB::ParallelFormattingOutputFormat, std::__1::allocator<DB::ParallelFormattingOutputFormat>, DB::ParallelFormattingOutputFormat::Params&, void>(std::__1::allocator<DB::ParallelFormattingOutputFormat> const&, DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3360:55 (clickhouse+0x173c1efb)
    #9 std::__1::shared_ptr<DB::ParallelFormattingOutputFormat> std::__1::make_shared<DB::ParallelFormattingOutputFormat, DB::ParallelFormattingOutputFormat::Params&, void>(DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3369:12 (clickhouse+0x173b8fa6)
    #10 DB::FormatFactory::getOutputFormatParallelIfPossible(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::WriteBuffer&, DB::Block const&, std::__1::shared_ptr<DB::Context const>, std::__1::function<void (std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::__1::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn> > > const&, unsigned long)>, std::__1::optional<DB::FormatSettings> const&) const obj-x86_64-linux-gnu/../src/Formats/FormatFactory.cpp:262:16 (clickhouse+0x173b8fa6)
    #11 DB::StorageFileSink::initialize() obj-x86_64-linux-gnu/../src/Storages/StorageFile.cpp:629:44 (clickhouse+0x16c19e53)
    #12 DB::StorageFileSink::StorageFileSink(std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, DB::CompressionMethod, std::__1::optional<DB::FormatSettings> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<DB::Context const>, int) obj-x86_64-linux-gnu/../src/Storages/StorageFile.cpp:606:9 (clickhouse+0x16c1ad89)
    #13 void std::__1::allocator<DB::StorageFileSink>::construct<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(DB::StorageFileSink*, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:886:28 (clickhouse+0x16c1a877)
    #14 void std::__1::allocator_traits<std::__1::allocator<DB::StorageFileSink> >::__construct<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(std::__1::integral_constant<bool, true>, std::__1::allocator<DB::StorageFileSink>&, DB::StorageFileSink*, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:519:21 (clickhouse+0x16c10d9a)
    #15 void std::__1::allocator_traits<std::__1::allocator<DB::StorageFileSink> >::construct<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(std::__1::allocator<DB::StorageFileSink>&, DB::StorageFileSink*, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:481:14 (clickhouse+0x16c10d9a)
    #16 std::__1::__shared_ptr_emplace<DB::StorageFileSink, std::__1::allocator<DB::StorageFileSink> >::__shared_ptr_emplace<std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(std::__1::allocator<DB::StorageFileSink>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2594:9 (clickhouse+0x16c10d9a)
    #17 std::__1::shared_ptr<DB::StorageFileSink> std::__1::allocate_shared<DB::StorageFileSink, std::__1::allocator<DB::StorageFileSink>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&, void>(std::__1::allocator<DB::StorageFileSink> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3360:55 (clickhouse+0x16c10d9a)
    #18 std::__1::shared_ptr<DB::StorageFileSink> std::__1::make_shared<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&, void>(std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3369:12 (clickhouse+0x16c10d9a)
    #19 DB::StorageFile::write(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::shared_ptr<DB::Context const>) obj-x86_64-linux-gnu/../src/Storages/StorageFile.cpp:781:16 (clickhouse+0x16c10d9a)
    #20 DB::buildPushingToViewsChain(std::__1::shared_ptr<DB::IStorage> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::shared_ptr<DB::Context const>, std::__1::shared_ptr<DB::IAST> const&, bool, DB::ThreadStatus*, std::__1::atomic<unsigned long>*, DB::Block const&) obj-x86_64-linux-gnu/../src/Processors/Transforms/buildPushingToViewsChain.cpp:351:30 (clickhouse+0x176581d0)
    #21 DB::InterpreterInsertQuery::buildChainImpl(std::__1::shared_ptr<DB::IStorage> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::Block const&, DB::ThreadStatus*, std::__1::atomic<unsigned long>*) obj-x86_64-linux-gnu/../src/Interpreters/InterpreterInsertQuery.cpp:209:15 (clickhouse+0x1624dc51)
    #22 DB::InterpreterInsertQuery::execute() obj-x86_64-linux-gnu/../src/Interpreters/InterpreterInsertQuery.cpp:376:24 (clickhouse+0x1624fdf0)
    #23 DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) obj-x86_64-linux-gnu/../src/Interpreters/executeQuery.cpp:630:32 (clickhouse+0x1682903b)
    #24 DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) obj-x86_64-linux-gnu/../src/Interpreters/executeQuery.cpp:945:30 (clickhouse+0x16826e61)
    #25 DB::TCPHandler::runImpl() obj-x86_64-linux-gnu/../src/Server/TCPHandler.cpp:318:24 (clickhouse+0x17391d77)
    #26 DB::TCPHandler::run() obj-x86_64-linux-gnu/../src/Server/TCPHandler.cpp:1840:9 (clickhouse+0x173a65c7)
    #27 Poco::Net::TCPServerConnection::start() obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerConnection.cpp:43:3 (clickhouse+0x1a72b802)
    #28 Poco::Net::TCPServerDispatcher::run() obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerDispatcher.cpp:115:20 (clickhouse+0x1a72c072)
    #29 Poco::PooledThread::run() obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/ThreadPool.cpp:199:14 (clickhouse+0x1a8b1155)
    #30 Poco::(anonymous namespace)::RunnableHolder::run() obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread.cpp:55:11 (clickhouse+0x1a8af2ef)
    #31 Poco::ThreadImpl::runnableEntry(void*) obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread_POSIX.cpp:345:27 (clickhouse+0x1a8ad967)

  Previous read of size 8 at 0x7b6401921f40 by thread T570 (mutexes: write M579411171523829504):
    #0 pthread_cond_wait <null> (clickhouse+0x9b91d4a)
    #1 std::__1::__libcpp_condvar_wait(pthread_cond_t*, pthread_mutex_t*) obj-x86_64-linux-gnu/../contrib/libcxx/include/__threading_support:436:10 (clickhouse+0x1d286f77)
    #2 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) obj-x86_64-linux-gnu/../contrib/libcxx/src/condition_variable.cpp:44:14 (clickhouse+0x1d286f77)
    #3 void std::__1::condition_variable::wait<DB::ParallelFormattingOutputFormat::collectorThreadFunction(std::__1::shared_ptr<DB::ThreadGroupStatus> const&)::$_1>(std::__1::unique_lock<std::__1::mutex>&, DB::ParallelFormattingOutputFormat::collectorThreadFunction(std::__1::shared_ptr<DB::ThreadGroupStatus> const&)::$_1) obj-x86_64-linux-gnu/../contrib/libcxx/include/__mutex_base:406:9 (clickhouse+0x174e2fe1)
    #4 DB::ParallelFormattingOutputFormat::collectorThreadFunction(std::__1::shared_ptr<DB::ThreadGroupStatus> const&) obj-x86_64-linux-gnu/../src/Processors/Formats/Impl/ParallelFormattingOutputFormat.cpp:113:39 (clickhouse+0x174e2fe1)
    #5 DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()::operator()() const obj-x86_64-linux-gnu/../src/Processors/Formats/Impl/ParallelFormattingOutputFormat.h:82:13 (clickhouse+0x173c5c44)
    #6 decltype(std::__1::forward<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&>(fp)()) std::__1::__invoke_constexpr<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&) obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3682:1 (clickhouse+0x173c5c44)
    #7 decltype(auto) std::__1::__apply_tuple_impl<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&, std::__1::tuple<>&>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&, std::__1::tuple<>&, std::__1::__tuple_indices<>) obj-x86_64-linux-gnu/../contrib/libcxx/include/tuple:1415:1 (clickhouse+0x173c5c44)
    #8 decltype(auto) std::__1::apply<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&, std::__1::tuple<>&>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&, std::__1::tuple<>&) obj-x86_64-linux-gnu/../contrib/libcxx/include/tuple:1424:1 (clickhouse+0x173c5c44)
    #9 ThreadFromGlobalPool::ThreadFromGlobalPool<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&)::'lambda'()::operator()() obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:188:13 (clickhouse+0x173c5c44)
    #10 decltype(std::__1::forward<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(fp)()) std::__1::__invoke<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&)::'lambda'()&>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676:1 (clickhouse+0x173c5ac1)
    #11 void std::__1::__invoke_void_return_wrapper<void>::__call<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&)::'lambda'()&>(ThreadFromGlobalPool::ThreadFromGlobalPool<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&)::'lambda'()&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__functional_base:348:9 (clickhouse+0x173c5ac1)
    #12 std::__1::__function::__default_alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&)::'lambda'(), void ()>::operator()() obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1608:12 (clickhouse+0x173c5ac1)
    #13 void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()>(DB::ParallelFormattingOutputFormat::ParallelFormattingOutputFormat(DB::ParallelFormattingOutputFormat::Params)::'lambda'()&&)::'lambda'(), void ()> >(std::__1::__function::__policy_storage const*) obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2089:16 (clickhouse+0x173c5ac1)
    #14 std::__1::__function::__policy_func<void ()>::operator()() const obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2221:16 (clickhouse+0x9c75f8d)
    #15 std::__1::function<void ()>::operator()() const obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2560:12 (clickhouse+0x9c75f8d)
    #16 ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:274:17 (clickhouse+0x9c75f8d)
    #17 void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()::operator()() const obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:139:73 (clickhouse+0x9c79750)
    #18 decltype(std::__1::forward<void>(fp)()) std::__1::__invoke<void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()>(void&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676:1 (clickhouse+0x9c79750)
    #19 void std::__1::__thread_execute<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>)::'lambda0'()>(std::__1::tuple<void, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()>&, std::__1::__tuple_indices<>) obj-x86_64-linux-gnu/../contrib/libcxx/include/thread:280:5 (clickhouse+0x9c79750)
    #20 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>)::'lambda0'()> >(void*) obj-x86_64-linux-gnu/../contrib/libcxx/include/thread:291:5 (clickhouse+0x9c79750)

  Location is heap block of size 1184 at 0x7b6401921c00 allocated by thread T659:
    #0 operator new(unsigned long) <null> (clickhouse+0x9c05f98)
    #1 void* std::__1::__libcpp_operator_new<unsigned long>(unsigned long) obj-x86_64-linux-gnu/../contrib/libcxx/include/new:235:10 (clickhouse+0x173c1e46)
    #2 std::__1::__libcpp_allocate(unsigned long, unsigned long) obj-x86_64-linux-gnu/../contrib/libcxx/include/new:261:10 (clickhouse+0x173c1e46)
    #3 std::__1::allocator<std::__1::__shared_ptr_emplace<DB::ParallelFormattingOutputFormat, std::__1::allocator<DB::ParallelFormattingOutputFormat> > >::allocate(unsigned long) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:840:38 (clickhouse+0x173c1e46)
    #4 std::__1::allocator_traits<std::__1::allocator<std::__1::__shared_ptr_emplace<DB::ParallelFormattingOutputFormat, std::__1::allocator<DB::ParallelFormattingOutputFormat> > > >::allocate(std::__1::allocator<std::__1::__shared_ptr_emplace<DB::ParallelFormattingOutputFormat, std::__1::allocator<DB::ParallelFormattingOutputFormat> > >&, unsigned long) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:468:21 (clickhouse+0x173c1e46)
    #5 std::__1::__allocation_guard<std::__1::allocator<std::__1::__shared_ptr_emplace<DB::ParallelFormattingOutputFormat, std::__1::allocator<DB::ParallelFormattingOutputFormat> > > >::__allocation_guard<std::__1::allocator<DB::ParallelFormattingOutputFormat> >(std::__1::allocator<DB::ParallelFormattingOutputFormat>, unsigned long) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/utilities.h:56:18 (clickhouse+0x173c1e46)
    #6 std::__1::shared_ptr<DB::ParallelFormattingOutputFormat> std::__1::allocate_shared<DB::ParallelFormattingOutputFormat, std::__1::allocator<DB::ParallelFormattingOutputFormat>, DB::ParallelFormattingOutputFormat::Params&, void>(std::__1::allocator<DB::ParallelFormattingOutputFormat> const&, DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3359:48 (clickhouse+0x173c1e46)
    #7 std::__1::shared_ptr<DB::ParallelFormattingOutputFormat> std::__1::make_shared<DB::ParallelFormattingOutputFormat, DB::ParallelFormattingOutputFormat::Params&, void>(DB::ParallelFormattingOutputFormat::Params&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3369:12 (clickhouse+0x173b8fa6)
    #8 DB::FormatFactory::getOutputFormatParallelIfPossible(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::WriteBuffer&, DB::Block const&, std::__1::shared_ptr<DB::Context const>, std::__1::function<void (std::__1::vector<COW<DB::IColumn>::immutable_ptr<DB::IColumn>, std::__1::allocator<COW<DB::IColumn>::immutable_ptr<DB::IColumn> > > const&, unsigned long)>, std::__1::optional<DB::FormatSettings> const&) const obj-x86_64-linux-gnu/../src/Formats/FormatFactory.cpp:262:16 (clickhouse+0x173b8fa6)
    #9 DB::StorageFileSink::initialize() obj-x86_64-linux-gnu/../src/Storages/StorageFile.cpp:629:44 (clickhouse+0x16c19e53)
    #10 DB::StorageFileSink::StorageFileSink(std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, DB::CompressionMethod, std::__1::optional<DB::FormatSettings> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<DB::Context const>, int) obj-x86_64-linux-gnu/../src/Storages/StorageFile.cpp:606:9 (clickhouse+0x16c1ad89)
    #11 void std::__1::allocator<DB::StorageFileSink>::construct<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(DB::StorageFileSink*, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:886:28 (clickhouse+0x16c1a877)
    #12 void std::__1::allocator_traits<std::__1::allocator<DB::StorageFileSink> >::__construct<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(std::__1::integral_constant<bool, true>, std::__1::allocator<DB::StorageFileSink>&, DB::StorageFileSink*, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:519:21 (clickhouse+0x16c10d9a)
    #13 void std::__1::allocator_traits<std::__1::allocator<DB::StorageFileSink> >::construct<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(std::__1::allocator<DB::StorageFileSink>&, DB::StorageFileSink*, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:481:14 (clickhouse+0x16c10d9a)
    #14 std::__1::__shared_ptr_emplace<DB::StorageFileSink, std::__1::allocator<DB::StorageFileSink> >::__shared_ptr_emplace<std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&>(std::__1::allocator<DB::StorageFileSink>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2594:9 (clickhouse+0x16c10d9a)
    #15 std::__1::shared_ptr<DB::StorageFileSink> std::__1::allocate_shared<DB::StorageFileSink, std::__1::allocator<DB::StorageFileSink>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&, void>(std::__1::allocator<DB::StorageFileSink> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3360:55 (clickhouse+0x16c10d9a)
    #16 std::__1::shared_ptr<DB::StorageFileSink> std::__1::make_shared<DB::StorageFileSink, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_lock<std::__1::shared_timed_mutex>, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&, void>(std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::unique_lock<std::__1::shared_timed_mutex>&&, int&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, DB::CompressionMethod&&, std::__1::optional<DB::FormatSettings>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<DB::Context const>&, int&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3369:12 (clickhouse+0x16c10d9a)
    #17 DB::StorageFile::write(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::shared_ptr<DB::Context const>) obj-x86_64-linux-gnu/../src/Storages/StorageFile.cpp:781:16 (clickhouse+0x16c10d9a)
    #18 DB::buildPushingToViewsChain(std::__1::shared_ptr<DB::IStorage> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::shared_ptr<DB::Context const>, std::__1::shared_ptr<DB::IAST> const&, bool, DB::ThreadStatus*, std::__1::atomic<unsigned long>*, DB::Block const&) obj-x86_64-linux-gnu/../src/Processors/Transforms/buildPushingToViewsChain.cpp:351:30 (clickhouse+0x176581d0)
    #19 DB::InterpreterInsertQuery::buildChainImpl(std::__1::shared_ptr<DB::IStorage> const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::Block const&, DB::ThreadStatus*, std::__1::atomic<unsigned long>*) obj-x86_64-linux-gnu/../src/Interpreters/InterpreterInsertQuery.cpp:209:15 (clickhouse+0x1624dc51)
    #20 DB::InterpreterInsertQuery::execute() obj-x86_64-linux-gnu/../src/Interpreters/InterpreterInsertQuery.cpp:376:24 (clickhouse+0x1624fdf0)
    #21 DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) obj-x86_64-linux-gnu/../src/Interpreters/executeQuery.cpp:630:32 (clickhouse+0x1682903b)
    #22 DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) obj-x86_64-linux-gnu/../src/Interpreters/executeQuery.cpp:945:30 (clickhouse+0x16826e61)
    #23 DB::TCPHandler::runImpl() obj-x86_64-linux-gnu/../src/Server/TCPHandler.cpp:318:24 (clickhouse+0x17391d77)
    #24 DB::TCPHandler::run() obj-x86_64-linux-gnu/../src/Server/TCPHandler.cpp:1840:9 (clickhouse+0x173a65c7)
    #25 Poco::Net::TCPServerConnection::start() obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerConnection.cpp:43:3 (clickhouse+0x1a72b802)
    #26 Poco::Net::TCPServerDispatcher::run() obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerDispatcher.cpp:115:20 (clickhouse+0x1a72c072)
    #27 Poco::PooledThread::run() obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/ThreadPool.cpp:199:14 (clickhouse+0x1a8b1155)
    #28 Poco::(anonymous namespace)::RunnableHolder::run() obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread.cpp:55:11 (clickhouse+0x1a8af2ef)
    #29 Poco::ThreadImpl::runnableEntry(void*) obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread_POSIX.cpp:345:27 (clickhouse+0x1a8ad967)

  Mutex M579411171523829504 is already destroyed.

  Thread T659 'TCPHandler' (tid=3345, running) created by thread T250 at:
    #0 pthread_create <null> (clickhouse+0x9b9125d)
    #1 Poco::ThreadImpl::startImpl(Poco::SharedPtr<Poco::Runnable, Poco::ReferenceCounter, Poco::ReleasePolicy<Poco::Runnable> >) obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread_POSIX.cpp:202:6 (clickhouse+0x1a8ad3b5)
    #2 Poco::Thread::start(Poco::Runnable&) obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread.cpp:128:2 (clickhouse+0x1a8aec2c)
    #3 Poco::PooledThread::start() obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/ThreadPool.cpp:85:10 (clickhouse+0x1a8b2f66)
    #4 Poco::ThreadPool::getThread() obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/ThreadPool.cpp:461:14 (clickhouse+0x1a8b2f66)
    #5 Poco::ThreadPool::startWithPriority(Poco::Thread::Priority, Poco::Runnable&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/ThreadPool.cpp:365:2 (clickhouse+0x1a8b3367)
    #6 Poco::Net::TCPServerDispatcher::enqueue(Poco::Net::StreamSocket const&) obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerDispatcher.cpp:152:17 (clickhouse+0x1a72c56e)
    #7 Poco::Net::TCPServer::run() obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServer.cpp:148:21 (clickhouse+0x1a72b087)
    #8 Poco::(anonymous namespace)::RunnableHolder::run() obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread.cpp:55:11 (clickhouse+0x1a8af2ef)
    #9 Poco::ThreadImpl::runnableEntry(void*) obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread_POSIX.cpp:345:27 (clickhouse+0x1a8ad967)

  Thread T570 'Collector' (tid=2842, running) created by thread T561 at:
    #0 pthread_create <null> (clickhouse+0x9b9125d)
    #1 std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) obj-x86_64-linux-gnu/../contrib/libcxx/include/__threading_support:509:10 (clickhouse+0x9c791c6)
    #2 std::__1::thread::thread<void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'(), void>(void&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/thread:307:16 (clickhouse+0x9c791c6)
    #3 void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>) obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:139:35 (clickhouse+0x9c745f4)
    #4 ThreadPoolImpl<std::__1::thread>::scheduleOrThrow(std::__1::function<void ()>, int, unsigned long) obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:171:5 (clickhouse+0x9c74f27)
    #5 ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PipelineExecutor::executeImpl(unsigned long)::$_1>(DB::PipelineExecutor::executeImpl(unsigned long)::$_1&&) obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:169:38 (clickhouse+0x17402c87)
    #6 void std::__1::allocator<ThreadFromGlobalPool>::construct<ThreadFromGlobalPool, DB::PipelineExecutor::executeImpl(unsigned long)::$_1>(ThreadFromGlobalPool*, DB::PipelineExecutor::executeImpl(unsigned long)::$_1&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:886:28 (clickhouse+0x17402c87)
    #7 void std::__1::allocator_traits<std::__1::allocator<ThreadFromGlobalPool> >::__construct<ThreadFromGlobalPool, DB::PipelineExecutor::executeImpl(unsigned long)::$_1>(std::__1::integral_constant<bool, true>, std::__1::allocator<ThreadFromGlobalPool>&, ThreadFromGlobalPool*, DB::PipelineExecutor::executeImpl(unsigned long)::$_1&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:519:21 (clickhouse+0x17402c87)
    #8 void std::__1::allocator_traits<std::__1::allocator<ThreadFromGlobalPool> >::construct<ThreadFromGlobalPool, DB::PipelineExecutor::executeImpl(unsigned long)::$_1>(std::__1::allocator<ThreadFromGlobalPool>&, ThreadFromGlobalPool*, DB::PipelineExecutor::executeImpl(unsigned long)::$_1&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__memory/allocator_traits.h:481:14 (clickhouse+0x17402c87)
    #9 void std::__1::vector<ThreadFromGlobalPool, std::__1::allocator<ThreadFromGlobalPool> >::__construct_one_at_end<DB::PipelineExecutor::executeImpl(unsigned long)::$_1>(DB::PipelineExecutor::executeImpl(unsigned long)::$_1&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/vector:926:5 (clickhouse+0x17400ee4)
    #10 ThreadFromGlobalPool& std::__1::vector<ThreadFromGlobalPool, std::__1::allocator<ThreadFromGlobalPool> >::emplace_back<DB::PipelineExecutor::executeImpl(unsigned long)::$_1>(DB::PipelineExecutor::executeImpl(unsigned long)::$_1&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/vector:1684:9 (clickhouse+0x17400ee4)
    #11 DB::PipelineExecutor::executeImpl(unsigned long) obj-x86_64-linux-gnu/../src/Processors/Executors/PipelineExecutor.cpp:266:21 (clickhouse+0x17400ee4)
    #12 DB::PipelineExecutor::execute(unsigned long) obj-x86_64-linux-gnu/../src/Processors/Executors/PipelineExecutor.cpp:81:9 (clickhouse+0x17400c93)
    #13 DB::threadFunction(DB::PullingAsyncPipelineExecutor::Data&, std::__1::shared_ptr<DB::ThreadGroupStatus>, unsigned long) obj-x86_64-linux-gnu/../src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:85:24 (clickhouse+0x17413f84)
    #14 DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0::operator()() const obj-x86_64-linux-gnu/../src/Processors/Executors/PullingAsyncPipelineExecutor.cpp:112:13 (clickhouse+0x17413f84)
    #15 decltype(std::__1::forward<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&>(fp)()) std::__1::__invoke_constexpr<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&) obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3682:1 (clickhouse+0x17413f84)
    #16 decltype(auto) std::__1::__apply_tuple_impl<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::__1::tuple<>&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::__1::tuple<>&, std::__1::__tuple_indices<>) obj-x86_64-linux-gnu/../contrib/libcxx/include/tuple:1415:1 (clickhouse+0x17413f84)
    #17 decltype(auto) std::__1::apply<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::__1::tuple<>&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&, std::__1::tuple<>&) obj-x86_64-linux-gnu/../contrib/libcxx/include/tuple:1424:1 (clickhouse+0x17413f84)
    #18 ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()::operator()() obj-x86_64-linux-gnu/../src/Common/ThreadPool.h:188:13 (clickhouse+0x17413f84)
    #19 decltype(std::__1::forward<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(fp)()) std::__1::__invoke<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676:1 (clickhouse+0x17413f84)
    #20 void std::__1::__invoke_void_return_wrapper<void>::__call<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&>(ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'()&) obj-x86_64-linux-gnu/../contrib/libcxx/include/__functional_base:348:9 (clickhouse+0x17413f84)
    #21 std::__1::__function::__default_alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'(), void ()>::operator()() obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:1608:12 (clickhouse+0x17413f84)
    #22 void std::__1::__function::__policy_invoker<void ()>::__call_impl<std::__1::__function::__default_alloc_func<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0>(DB::PullingAsyncPipelineExecutor::pull(DB::Chunk&, unsigned long)::$_0&&)::'lambda'(), void ()> >(std::__1::__function::__policy_storage const*) obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2089:16 (clickhouse+0x17413f84)
    #23 std::__1::__function::__policy_func<void ()>::operator()() const obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2221:16 (clickhouse+0x9c75f8d)
    #24 std::__1::function<void ()>::operator()() const obj-x86_64-linux-gnu/../contrib/libcxx/include/functional:2560:12 (clickhouse+0x9c75f8d)
    #25 ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:274:17 (clickhouse+0x9c75f8d)
    #26 void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()::operator()() const obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:139:73 (clickhouse+0x9c79750)
    #27 decltype(std::__1::forward<void>(fp)()) std::__1::__invoke<void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()>(void&&) obj-x86_64-linux-gnu/../contrib/libcxx/include/type_traits:3676:1 (clickhouse+0x9c79750)
    #28 void std::__1::__thread_execute<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>)::'lambda0'()>(std::__1::tuple<void, void ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, int, std::__1::optional<unsigned long>)::'lambda0'()>&, std::__1::__tuple_indices<>) obj-x86_64-linux-gnu/../contrib/libcxx/include/thread:280:5 (clickhouse+0x9c79750)
    #29 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>)::'lambda0'()> >(void*) obj-x86_64-linux-gnu/../contrib/libcxx/include/thread:291:5 (clickhouse+0x9c79750)

SUMMARY: ThreadSanitizer: data race (/usr/bin/clickhouse+0x9b9287a) in pthread_cond_destroy
```

cc: @nikitamikhaylov 
{
        if (save_totals_and_extremes_in_statistics)
        {
            std::lock_guard lock(statistics_mutex);
            statistics.totals = std::move(totals);
        }
        else
        {
            addChunk(std::move(totals), ProcessingUnitType::TOTALS,  true);
            are_totals_written = true;
        }
    }
    void consumeExtremes(Chunk extremes) override
    {
        if (save_totals_and_extremes_in_statistics)
        {
            std::lock_guard lock(statistics_mutex);
            statistics.extremes = std::move(extremes);
        }
        else
        {
            addChunk(std::move(extremes), ProcessingUnitType::EXTREMES,  true);
        }
    }
    void finalizeImpl() override;
    InternalFormatterCreator internal_formatter_creator;
    
    enum ProcessingUnitStatus