https://s3.amazonaws.com/clickhouse-test-reports/0/00666a6a4ccb5f2dd3591ba6f95fb4d6808fe189/stress_test__thread__actions_.html

```
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.552991 [ 502 ] {} <Fatal> BaseDaemon: (version 21.13.1.1260, build id: 2481E82FAE0E4CC8) (from thread 499) Terminate called for uncaught exception:
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553100 [ 502 ] {} <Fatal> BaseDaemon: Code: 84. DB::Exception: Could not flush part '/var/lib/clickhouse/store/e50/e5098279-3444-45c0-a509-82793444d5c0/all_1_1_0/'. Part in /var/lib/clickhouse/store/e50/e5098279-3444-45c0-a509-82793444d5c0/all_1_1_0 already exists. (DIRECTORY_ALREADY_EXISTS), Stack trace (when copying this message, always include the lines below):
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553196 [ 502 ] {} <Fatal> BaseDaemon: 
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553254 [ 502 ] {} <Fatal> BaseDaemon: 0. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/exception:0: Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x1b28d67b in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553330 [ 502 ] {} <Fatal> BaseDaemon: 1. ./obj-x86_64-linux-gnu/../src/Common/Exception.cpp:57: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0xa0e77fc in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553398 [ 502 ] {} <Fatal> BaseDaemon: 2. ./obj-x86_64-linux-gnu/../src/Storages/MergeTree/MergeTreeDataPartInMemory.cpp:0: DB::MergeTreeDataPartInMemory::flushToDisk(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&) const @ 0x178d84e6 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553473 [ 502 ] {} <Fatal> BaseDaemon: 3. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:3211: DB::MergeTreeData::flushAllInMemoryPartsIfNeeded() @ 0x1785826f in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553535 [ 502 ] {} <Fatal> BaseDaemon: 4. ./obj-x86_64-linux-gnu/../src/Storages/StorageMergeTree.cpp:145: DB::StorageMergeTree::flush() @ 0x17ab9cda in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553595 [ 502 ] {} <Fatal> BaseDaemon: 5. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__tree:182: DB::DatabaseWithOwnTablesBase::shutdown() @ 0x163eddea in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553658 [ 502 ] {} <Fatal> BaseDaemon: 6. ./obj-x86_64-linux-gnu/../src/Databases/DatabaseReplicated.cpp:759: DB::DatabaseReplicated::shutdown() @ 0x163e0891 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553713 [ 502 ] {} <Fatal> BaseDaemon: 7. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/__tree:182: DB::DatabaseCatalog::shutdownImpl() @ 0x1659765a in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553769 [ 502 ] {} <Fatal> BaseDaemon: 8. ./obj-x86_64-linux-gnu/../src/Interpreters/DatabaseCatalog.cpp:593: DB::DatabaseCatalog::shutdown() @ 0x1659e90a in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553867 [ 502 ] {} <Fatal> BaseDaemon: 9. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2835: DB::ContextSharedPart::shutdown() @ 0x16544c61 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553924 [ 502 ] {} <Fatal> BaseDaemon: 10. ./obj-x86_64-linux-gnu/../src/Interpreters/Context.cpp:2641: DB::Context::shutdown() @ 0x1653ab9b in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.553984 [ 502 ] {} <Fatal> BaseDaemon: 11. ./obj-x86_64-linux-gnu/../programs/server/Server.cpp:1073: basic_scope_guard<DB::Server::main(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> > > > const&)::$_6>::~basic_scope_guard() @ 0xa0c440e in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554056 [ 502 ] {} <Fatal> BaseDaemon: 12. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/vector:463: DB::Server::main(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> > > > const&) @ 0xa0beee5 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554132 [ 502 ] {} <Fatal> BaseDaemon: 13. ./obj-x86_64-linux-gnu/../contrib/poco/Util/src/Application.cpp:0: Poco::Util::Application::run() @ 0x1b1c09cb in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554185 [ 502 ] {} <Fatal> BaseDaemon: 14. ./obj-x86_64-linux-gnu/../programs/server/Server.cpp:0: DB::Server::run() @ 0xa0b1515 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554241 [ 502 ] {} <Fatal> BaseDaemon: 15. ./obj-x86_64-linux-gnu/../contrib/poco/Util/src/ServerApplication.cpp:0: Poco::Util::ServerApplication::run(int, char**) @ 0x1b1dff87 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554302 [ 502 ] {} <Fatal> BaseDaemon: 16. ./obj-x86_64-linux-gnu/../programs/server/Server.cpp:0: mainEntryClickHouseServer(int, char**) @ 0xa0afbd7 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554359 [ 502 ] {} <Fatal> BaseDaemon: 17. ./obj-x86_64-linux-gnu/../programs/main.cpp:0: main @ 0xa0ae0bb in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554416 [ 502 ] {} <Fatal> BaseDaemon: 18. __libc_start_main @ 0x7f7346fe00b3 in ?
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554466 [ 502 ] {} <Fatal> BaseDaemon: 19. _start @ 0xa00da6e in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.554523 [ 502 ] {} <Fatal> BaseDaemon:  (version 21.13.1.1260)
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.555180 [ 33770 ] {} <Fatal> BaseDaemon: ########################################
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.555343 [ 33770 ] {} <Fatal> BaseDaemon: (version 21.13.1.1260, build id: 2481E82FAE0E4CC8) (from thread 499) (no query) Received signal Aborted (6)
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.555424 [ 33770 ] {} <Fatal> BaseDaemon: 
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.555572 [ 33770 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f7346fff18b 0x7f7346fde859 0xa03d623 0x15d8f97c 0x1ddd3f54 0x1ddd3e65 0xa0aea7b 0xa0c5947 0xa0beee5 0x1b1c09cb 0xa0b1515 0x1b1dff87 0xa0afbd7 0xa0ae0bb 0x7f7346fe00b3 0xa00da6e
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.555726 [ 33770 ] {} <Fatal> BaseDaemon: 5. gsignal @ 0x7f7346fff18b in ?
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:31:53.555824 [ 33770 ] {} <Fatal> BaseDaemon: 6. abort @ 0x7f7346fde859 in ?
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:01.505650 [ 33770 ] {} <Fatal> BaseDaemon: 7. abort @ 0xa03d623 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:01.622760 [ 33770 ] {} <Fatal> BaseDaemon: 8. ./obj-x86_64-linux-gnu/../base/daemon/BaseDaemon.cpp:420: terminate_handler() @ 0x15d8f97c in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:01.660017 [ 33770 ] {} <Fatal> BaseDaemon: 9. ./obj-x86_64-linux-gnu/../contrib/libcxxabi/src/cxa_handlers.cpp:61: std::__terminate(void (*)()) @ 0x1ddd3f54 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:01.697107 [ 33770 ] {} <Fatal> BaseDaemon: 10. ./obj-x86_64-linux-gnu/../contrib/libcxxabi/src/cxa_handlers.cpp:0: std::terminate() @ 0x1ddd3e65 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:09.985694 [ 33770 ] {} <Fatal> BaseDaemon: 11. ? @ 0xa0aea7b in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:10.523640 [ 33770 ] {} <Fatal> BaseDaemon: 12. ./obj-x86_64-linux-gnu/../base/base/../base/scope_guard.h:44: ? @ 0xa0c5947 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:10.703962 [ 33770 ] {} <Fatal> BaseDaemon: 13.1. inlined from ./obj-x86_64-linux-gnu/../contrib/libcxx/include/vector:463: ~__vector_base
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:10.704103 [ 33770 ] {} <Fatal> BaseDaemon: 13.2. inlined from ../contrib/libcxx/include/vector:557: ~vector
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:10.704172 [ 33770 ] {} <Fatal> BaseDaemon: 13. ../programs/server/Server.cpp:1616: DB::Server::main(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> > > > const&) @ 0xa0beee5 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:10.816747 [ 33770 ] {} <Fatal> BaseDaemon: 14. ./obj-x86_64-linux-gnu/../contrib/poco/Util/src/Application.cpp:0: Poco::Util::Application::run() @ 0x1b1c09cb in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:11.161911 [ 33770 ] {} <Fatal> BaseDaemon: 15. ./obj-x86_64-linux-gnu/../programs/server/Server.cpp:0: DB::Server::run() @ 0xa0b1515 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:11.212126 [ 33770 ] {} <Fatal> BaseDaemon: 16. ./obj-x86_64-linux-gnu/../contrib/poco/Util/src/ServerApplication.cpp:0: Poco::Util::ServerApplication::run(int, char**) @ 0x1b1dff87 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:11.546145 [ 33770 ] {} <Fatal> BaseDaemon: 17. ./obj-x86_64-linux-gnu/../programs/server/Server.cpp:0: mainEntryClickHouseServer(int, char**) @ 0xa0afbd7 in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:11.569914 [ 33770 ] {} <Fatal> BaseDaemon: 18. ./obj-x86_64-linux-gnu/../programs/main.cpp:0: main @ 0xa0ae0bb in /usr/bin/clickhouse
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:11.570059 [ 33770 ] {} <Fatal> BaseDaemon: 19. __libc_start_main @ 0x7f7346fe00b3 in ?
/var/log/clickhouse-server/clickhouse-server.log.2:2021.12.24 18:32:15.936510 [ 497 ] {} <Fatal> Application: Child process was terminated by signal 6.
```

cc: @CurtizJ, @nautaa  

context_,
        date_column_name,
        merging_params_,
        std::move(storage_settings_),
        false,      
        attach)
    , reader(*this)
    , writer(*this)
    , merger_mutator(*this,
        getContext()->getSettingsRef().background_merges_mutations_concurrency_ratio *
        getContext()->getSettingsRef().background_pool_size)
{
    loadDataParts(has_force_restore_data_flag);
    if (!attach && !getDataParts().empty())
        throw Exception("Data directory for table already containing data parts - probably it was unclean DROP table or manual intervention. You must either clear directory by hand or use ATTACH TABLE instead of CREATE TABLE if you need to use that parts.", ErrorCodes::INCORRECT_DATA);
    increment.set(getMaxBlockNumber());
    loadMutations();
    loadDeduplicationLog();
}
void StorageMergeTree::startup()
{
    clearOldPartsFromFilesystem();
    clearOldWriteAheadLogs();
    clearEmptyParts();
    
    
    clearOldTemporaryDirectories(merger_mutator, 0);
    
    time_after_previous_cleanup_parts.restart();
    time_after_previous_cleanup_temporary_directories.restart();