https://s3.amazonaws.com/clickhouse-test-reports/36579/bff54af46eecc9b33bcc1aeceda32876057f2ce1/stateless_tests__ubsan__actions_.html

```
2022.04.25 02:01:53.825389 [ 388 ] {} <Trace> BaseDaemon: Received signal -1
2022.04.25 02:01:53.825461 [ 388 ] {} <Fatal> BaseDaemon: (version 22.5.1.1, build id: ACED567A0CAB7BCA) (from thread 598) Terminate called for uncaught exception:
2022.04.25 02:01:53.825491 [ 388 ] {} <Fatal> BaseDaemon: Code: 49. DB::Exception: Part 4_4_83_1 intersects next part 4_54_54_1. It is a bug or a result of manual intervention in the ZooKeeper data. (LOGICAL_ERROR), Stack trace (when copying this message, always include the lines below):
2022.04.25 02:01:53.825515 [ 388 ] {} <Fatal> BaseDaemon: 
2022.04.25 02:01:53.825533 [ 388 ] {} <Fatal> BaseDaemon: 0. ./build_docker/../contrib/libcxx/include/exception:133: Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x26685052 in /usr/bin/clickhouse
2022.04.25 02:01:53.825553 [ 388 ] {} <Fatal> BaseDaemon: 1. ./build_docker/../src/Common/Exception.cpp:58: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0xfd144cf in /usr/bin/clickhouse
2022.04.25 02:01:53.825575 [ 388 ] {} <Fatal> BaseDaemon: 2. ./build_docker/../contrib/libcxx/include/string:1445: DB::Exception::Exception<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> > >(int, fmt::v8::basic_format_string<char, fmt::v8::type_identity<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>::type, fmt::v8::type_identity<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::type>, 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> >&&) @ 0x145736f7 in /usr/bin/clickhouse
2022.04.25 02:01:53.825605 [ 388 ] {} <Fatal> BaseDaemon: 3. ./build_docker/../src/Storages/MergeTree/ActiveDataPartSet.cpp:0: DB::ActiveDataPartSet::add(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, 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> > > >*) @ 0x240e141d in /usr/bin/clickhouse
2022.04.25 02:01:53.825634 [ 388 ] {} <Fatal> BaseDaemon: 4. ./build_docker/../src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp:0: DB::ReplicatedMergeTreeQueue::insertUnlocked(std::__1::shared_ptr<DB::ReplicatedMergeTreeLogEntry> const&, std::__1::optional<long>&, std::__1::lock_guard<std::__1::mutex>&) @ 0x244852c2 in /usr/bin/clickhouse
2022.04.25 02:01:53.825653 [ 388 ] {} <Fatal> BaseDaemon: 5. ./build_docker/../contrib/libcxx/include/string:1445: DB::ReplicatedMergeTreeQueue::pullLogsToQueue(std::__1::shared_ptr<zkutil::ZooKeeper>, std::__1::function<void (Coordination::WatchResponse const&)>, DB::ReplicatedMergeTreeQueue::PullLogsReason) @ 0x2448e437 in /usr/bin/clickhouse
2022.04.25 02:01:53.825681 [ 388 ] {} <Fatal> BaseDaemon: 6. ./build_docker/../contrib/libcxx/include/__functional/function.h:813: DB::StorageReplicatedMergeTree::queueUpdatingTask() @ 0x23e71979 in /usr/bin/clickhouse
2022.04.25 02:01:53.825701 [ 388 ] {} <Fatal> BaseDaemon: 7. ./build_docker/../src/Common/Stopwatch.h:49: DB::BackgroundSchedulePoolTaskInfo::execute() @ 0x225133e0 in /usr/bin/clickhouse
2022.04.25 02:01:53.825718 [ 388 ] {} <Fatal> BaseDaemon: 8. ./build_docker/../contrib/poco/Foundation/include/Poco/AutoPtr.h:90: DB::BackgroundSchedulePool::threadFunction() @ 0x225151fe in /usr/bin/clickhouse
2022.04.25 02:01:53.825742 [ 388 ] {} <Fatal> BaseDaemon: 9. ./build_docker/../src/Core/BackgroundSchedulePool.cpp:0: decltype(static_cast<DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1>(fp)()) std::__1::__invoke<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1>(DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1&&)::'lambda'()&>(DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1&&) @ 0x22515c7f in /usr/bin/clickhouse
2022.04.25 02:01:53.825770 [ 388 ] {} <Fatal> BaseDaemon: 10. ./build_docker/../contrib/libcxx/include/__functional/function.h:1157: ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xfde887a in /usr/bin/clickhouse
2022.04.25 02:01:53.825797 [ 388 ] {} <Fatal> BaseDaemon: 11. ./build_docker/../src/Common/ThreadPool.cpp:0: 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
2022.04.25 02:01:53.825819 [ 388 ] {} <Trace> BaseDaemon: Received signal 6
2022.04.25 02:01:53.825955 [ 215703 ] {} <Fatal> BaseDaemon: ########################################
2022.04.25 02:01:53.825979 [ 215703 ] {} <Fatal> BaseDaemon: (version 22.5.1.1, build id: ACED567A0CAB7BCA) (from thread 598) (no query) Received signal Aborted (6)
2022.04.25 02:01:53.825996 [ 215703 ] {} <Fatal> BaseDaemon: 
2022.04.25 02:01:53.826041 [ 215703 ] {} <Fatal> BaseDaemon: Stack trace: 0x7f924351803b 0x7f92434f7859 0x221fc733 0x279b58c8 0x279b5835 0x2448fd97 0x23e71979 0x225133e0 0x225151fe 0x22515c7f 0xfde887a 0xfdeb342 0x7f92436cf609 0x7f92435f4163
2022.04.25 02:01:53.826081 [ 215703 ] {} <Fatal> BaseDaemon: 3. gsignal @ 0x7f924351803b in ?
2022.04.25 02:01:53.826107 [ 215703 ] {} <Fatal> BaseDaemon: 4. abort @ 0x7f92434f7859 in ?
2022.04.25 02:01:53.849168 [ 215703 ] {} <Fatal> BaseDaemon: 5. ./build_docker/../base/daemon/BaseDaemon.cpp:443: terminate_handler() @ 0x221fc733 in /usr/bin/clickhouse
2022.04.25 02:01:53.856352 [ 215703 ] {} <Fatal> BaseDaemon: 6. ./build_docker/../contrib/libcxxabi/src/cxa_handlers.cpp:61: std::__terminate(void (*)()) @ 0x279b58c8 in /usr/bin/clickhouse
2022.04.25 02:01:53.864493 [ 215703 ] {} <Fatal> BaseDaemon: 7. ./build_docker/../contrib/libcxxabi/src/cxa_handlers.cpp:0: std::terminate() @ 0x279b5835 in /usr/bin/clickhouse
2022.04.25 02:01:53.955431 [ 215703 ] {} <Fatal> BaseDaemon: 8. ./build_docker/../src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp:712: DB::ReplicatedMergeTreeQueue::pullLogsToQueue(std::__1::shared_ptr<zkutil::ZooKeeper>, std::__1::function<void (Coordination::WatchResponse const&)>, DB::ReplicatedMergeTreeQueue::PullLogsReason) @ 0x2448fd97 in /usr/bin/clickhouse
2022.04.25 02:01:54.168000 [ 215703 ] {} <Fatal> BaseDaemon: 9.1. inlined from ./build_docker/../contrib/libcxx/include/__functional/function.h:813: ~__policy_func
2022.04.25 02:01:54.168025 [ 215703 ] {} <Fatal> BaseDaemon: 9.2. inlined from ../contrib/libcxx/include/__functional/function.h:1171: ~function
2022.04.25 02:01:54.168039 [ 215703 ] {} <Fatal> BaseDaemon: 9. ../src/Storages/StorageReplicatedMergeTree.cpp:2907: DB::StorageReplicatedMergeTree::queueUpdatingTask() @ 0x23e71979 in /usr/bin/clickhouse
2022.04.25 02:01:54.181266 [ 215703 ] {} <Fatal> BaseDaemon: 10.1. inlined from ./build_docker/../src/Common/Stopwatch.h:49: Stopwatch::elapsedNanoseconds() const
2022.04.25 02:01:54.181298 [ 215703 ] {} <Fatal> BaseDaemon: 10.2. inlined from ../src/Common/Stopwatch.h:51: Stopwatch::elapsedMilliseconds() const
2022.04.25 02:01:54.181317 [ 215703 ] {} <Fatal> BaseDaemon: 10. ../src/Core/BackgroundSchedulePool.cpp:106: DB::BackgroundSchedulePoolTaskInfo::execute() @ 0x225133e0 in /usr/bin/clickhouse
2022.04.25 02:01:54.195768 [ 215703 ] {} <Fatal> BaseDaemon: 11.1. inlined from ./build_docker/../contrib/poco/Foundation/include/Poco/AutoPtr.h:90: ~AutoPtr
2022.04.25 02:01:54.195795 [ 215703 ] {} <Fatal> BaseDaemon: 11. ../src/Core/BackgroundSchedulePool.cpp:260: DB::BackgroundSchedulePool::threadFunction() @ 0x225151fe in /usr/bin/clickhouse
2022.04.25 02:01:54.210701 [ 215703 ] {} <Fatal> BaseDaemon: 12.1. inlined from ./build_docker/../src/Core/BackgroundSchedulePool.cpp:0: operator()
2022.04.25 02:01:54.210734 [ 215703 ] {} <Fatal> BaseDaemon: 12. ../contrib/libcxx/include/type_traits:3640: decltype(static_cast<DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1>(fp)()) std::__1::__invoke<ThreadFromGlobalPool::ThreadFromGlobalPool<DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1>(DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1&&)::'lambda'()&>(DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, unsigned long, char const*)::$_1&&) @ 0x22515c7f in /usr/bin/clickhouse
2022.04.25 02:01:54.226362 [ 215703 ] {} <Fatal> BaseDaemon: 13.1. inlined from ./build_docker/../contrib/libcxx/include/__functional/function.h:1157: std::__1::function<void ()>::operator=(std::nullptr_t)
2022.04.25 02:01:54.226413 [ 215703 ] {} <Fatal> BaseDaemon: 13. ../src/Common/ThreadPool.cpp:284: ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0xfde887a in /usr/bin/clickhouse
2022.04.25 02:01:54.246083 [ 215703 ] {} <Fatal> BaseDaemon: 14. ./build_docker/../src/Common/ThreadPool.cpp:0: 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*) @ 0xfdeb342 in /usr/bin/clickhouse
2022.04.25 02:01:54.246136 [ 215703 ] {} <Fatal> BaseDaemon: 15. ? @ 0x7f92436cf609 in ?
2022.04.25 02:01:54.246162 [ 215703 ] {} <Fatal> BaseDaemon: 16. __clone @ 0x7f92435f4163 in ?
2022.04.25 02:01:54.591891 [ 215703 ] {} <Fatal> BaseDaemon: Calculated checksum of the binary: 7833E7805745E43565B3841080D21010. There is no information about the reference checksum.
```
zkutil::ZooKeeperPtr & zookeeper,
    const DataPartsVector & parts,
    const String & merged_name,
    const UUID & merged_part_uuid,
    const MergeTreeDataPartType & merged_part_type,
    bool deduplicate,
    const Names & deduplicate_by_columns,
    ReplicatedMergeTreeLogEntryData * out_log_entry,
    int32_t log_version,
    MergeType merge_type)
{
    std::vector<std::future<Coordination::ExistsResponse>> exists_futures;
    exists_futures.reserve(parts.size());
    for (const auto & part : parts)
        exists_futures.emplace_back(zookeeper->asyncExists(fs::path(replica_path) / "parts" / part->name));
    bool all_in_zk = true;
    for (size_t i = 0; i < parts.size(); ++i)
    {
        
        if (exists_futures[i].get().error == Coordination::Error::ZNONODE)
        {
            all_in_zk = false;
            const auto & part = parts[i];
            if (part->modification_time + MAX_AGE_OF_LOCAL_PART_THAT_WASNT_ADDED_TO_ZOOKEEPER < time(nullptr))
            {
                LOG_WARNING(log, "Part {} (that was selected for merge) with age {} seconds exists locally but not in ZooKeeper. Won't do merge with that part and will check it.", part->name, (time(nullptr) - part->modification_time));
                enqueuePartForCheck(part->name);
            }
        }