mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 10:52:30 +00:00
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#include <Storages/MergeTree/MergeTreeMutationStatus.h>
|
|
|
|
#include <Common/Exception.h>
|
|
#include <boost/algorithm/string/join.hpp>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int UNFINISHED;
|
|
extern const int LOGICAL_ERROR;
|
|
}
|
|
|
|
void checkMutationStatus(std::optional<MergeTreeMutationStatus> & status, const std::set<String> & mutation_ids)
|
|
{
|
|
if (mutation_ids.empty())
|
|
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot check mutation status because no mutation ids provided");
|
|
|
|
if (!status)
|
|
{
|
|
throw Exception(ErrorCodes::UNFINISHED, "Mutation {} was killed", *mutation_ids.begin());
|
|
}
|
|
else if (!status->is_done && !status->latest_fail_reason.empty())
|
|
{
|
|
throw Exception(
|
|
ErrorCodes::UNFINISHED,
|
|
"Exception happened during execution of mutation{} '{}' with part '{}' reason: '{}'. This error maybe retryable or not. "
|
|
"In case of unretryable error, mutation can be killed with KILL MUTATION query",
|
|
mutation_ids.size() > 1 ? "s" : "",
|
|
boost::algorithm::join(mutation_ids, ", "),
|
|
status->latest_failed_part,
|
|
status->latest_fail_reason);
|
|
}
|
|
}
|
|
|
|
}
|