ClickHouse/src/Storages/MergeTree/MergeTreeMutationStatus.cpp

38 lines
1.2 KiB
C++
Raw Normal View History

#include <Storages/MergeTree/MergeTreeMutationStatus.h>
2020-07-22 19:29:54 +00:00
#include <Common/Exception.h>
#include <boost/algorithm/string/join.hpp>
namespace DB
{
namespace ErrorCodes
{
extern const int UNFINISHED;
2020-07-31 11:37:16 +00:00
extern const int LOGICAL_ERROR;
}
2020-07-31 11:37:16 +00:00
void checkMutationStatus(std::optional<MergeTreeMutationStatus> & status, const std::set<String> & mutation_ids)
{
2020-07-31 11:37:16 +00:00
if (mutation_ids.empty())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot check mutation status because no mutation ids provided");
if (!status)
{
2020-07-31 11:37:16 +00:00
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);
}
}
}