https://s3.amazonaws.com/clickhouse-test-reports/0/dd132d1bebfe4d1d4207ef185ca7e2abfcd01df9/stress_test__undefined__actions_.html

```
Thread 546 (Thread 0x7fb992ffd700 (LWP 3332)):
#0  0x00007fc0bd68a170 in __lll_lock_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007fc0bd6820a3 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x000000000ff4c55e in pthread_mutex_lock (arg=0x7fbf9bda70a8) at ../src/Common/ThreadFuzzer.cpp:317
#3  0x00000000283d7c49 in std::__1::__libcpp_mutex_lock (__m=0x7fbf9bda70a8) at ../contrib/libcxx/include/__threading_support:303
#4  std::__1::mutex::lock (this=0x7fbf9bda70a8) at ../contrib/libcxx/src/mutex.cpp:33
#5  0x0000000024bdc471 in std::__1::unique_lock<std::__1::mutex>::unique_lock (this=0x7fb992ff4080, __m=...) at ../contrib/libcxx/include/__mutex_base:119
#6  DB::MergeTreeData::lockParts (this=0x7fbf9bda6bf0) at ../src/Storages/MergeTree/MergeTreeData.h:229
#7  DB::MergeTreeData::removePartsFromWorkingSet (this=this@entry=0x7fbf9bda6bf0, txn=txn@entry=0x7fbc4e3060b8, remove=..., clear_without_timeout=true, acquired_lock=acquired_lock@entry=0x0) at ../src/Storages/MergeTree/MergeTreeData.cpp:2960
#8  0x0000000024c02d56 in DB::MergeTreeData::Transaction::rollback (this=0x7fb992ff42f0) at ../src/Storages/MergeTree/MergeTreeData.cpp:4846
#9  0x00000000248813d3 in DB::MergeTreeData::Transaction::~Transaction (this=0x7fbf9bda70a8) at ../src/Storages/MergeTree/MergeTreeData.h:272
#10 0x0000000024ef032b in DB::MergeTreeSink::finishDelayedChunk (this=0x7fbc4e2f7458) at ../src/Storages/MergeTree/MergeTreeSink.cpp:162
#11 0x00000000254d945c in std::__1::__function::__policy_func<void ()>::operator()() const (this=0x7fb992ff4520) at ../contrib/libcxx/include/__functional/function.h:843
#12 std::__1::function<void ()>::operator()() const (this=0x7fb992ff4520) at ../contrib/libcxx/include/__functional/function.h:1184
#13 DB::runStep(std::__1::function<void ()>, DB::ThreadStatus*, std::__1::atomic<unsigned long>*) (step=..., thread_status=thread_status@entry=0x0, elapsed_ms=0x0) at ../src/Processors/Transforms/ExceptionKeepingTransform.cpp:115
#14 0x00000000254d8e03 in DB::ExceptionKeepingTransform::work (this=0x7fbc4e2f7458) at ../src/Processors/Transforms/ExceptionKeepingTransform.cpp:187
#15 0x0000000025160000 in DB::executeJob (node=0x7fbc4db32180, read_progress_callback=0x7fbc4e9472c0) at ../src/Processors/Executors/ExecutionThreadContext.cpp:47
#16 0x000000002515fbd7 in DB::ExecutionThreadContext::executeTask (this=0x7fbcbc10efd0) at ../src/Processors/Executors/ExecutionThreadContext.cpp:86
#17 0x00000000251521b3 in DB::PipelineExecutor::executeStepImpl (this=this@entry=0x7fbc4c5ac9d8, thread_num=thread_num@entry=0, yield_flag=yield_flag@entry=0x0) at ../src/Processors/Executors/PipelineExecutor.cpp:222
#18 0x0000000025151e98 in DB::PipelineExecutor::executeStep (this=0x7fbc4c5ac9d8, yield_flag=0x0) at ../src/Processors/Executors/PipelineExecutor.cpp:119
#19 0x00000000250e0f1e in DB::TCPHandler::processInsertQuery()::$_0::operator()<DB::PushingPipelineExecutor>(DB::PushingPipelineExecutor&) const (executor=..., this=<optimized out>) at ../src/Server/TCPHandler.cpp:652
#20 DB::TCPHandler::processInsertQuery (this=this@entry=0x7fb208429e90) at ../src/Server/TCPHandler.cpp:663
#21 0x00000000250d4e22 in DB::TCPHandler::runImpl (this=this@entry=0x7fb208429e90) at ../src/Server/TCPHandler.cpp:340
#22 0x00000000250f2156 in DB::TCPHandler::run (this=0x7fb208429e90) at ../src/Server/TCPHandler.cpp:1797
#23 0x0000000025ec7cac in Poco::Net::TCPServerConnection::start (this=0x7fbf9bda70a8) at ../contrib/poco/Net/src/TCPServerConnection.cpp:43
#24 0x0000000025ec8185 in Poco::Net::TCPServerDispatcher::run (this=0x37962300) at ../contrib/poco/Net/src/TCPServerDispatcher.cpp:115
#25 0x00000000260387c7 in Poco::PooledThread::run (this=0x7fbb4001dde0) at ../contrib/poco/Foundation/src/ThreadPool.cpp:199
#26 0x00000000260362cc in Poco::ThreadImpl::runnableEntry (pThread=0x7fbb4001de18) at ../contrib/poco/Foundation/src/Thread_POSIX.cpp:345
#27 0x00007fc0bd67f609 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#28 0x00007fc0bd5a4133 in clone () from /lib/x86_64-linux-gnu/libc.so.6
```

Introduced in #38380
#include "StorageMergeTree.h"
#include <optional>
#include <base/sort.h>
#include <Databases/IDatabase.h>
#include <Common/escapeForFileName.h>
#include <Common/typeid_cast.h>
#include <Common/ThreadPool.h>
#include <Interpreters/InterpreterAlterQuery.h>
#include <Interpreters/PartLog.h>
#include <Interpreters/MutationsInterpreter.h>
#include <Interpreters/Context.h>
#include <Interpreters/TransactionLog.h>
#include <IO/copyData.h>
#include <Parsers/ASTCheckQuery.h>
#include <Parsers/ASTFunction.h>
#include <Parsers/ASTLiteral.h>
#include <Parsers/ASTPartition.h>
#include <Parsers/ASTSetQuery.h>
#include <Parsers/queryToString.h>
#include <Parsers/formatAST.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Storages/MergeTree/ActiveDataPartSet.h>
#include <Storages/AlterCommands.h>
#include <Storages/PartitionCommands.h>
#include <Storages/MergeTree/MergeTreeSink.h>
#include <Storages/MergeTree/MergeTreeDataPartInMemory.h>