Better exception message [#METR-21479].

This commit is contained in:
Alexey Milovidov 2016-05-26 00:35:57 +03:00
parent 1a0ff5bdea
commit f2ccbc9802
4 changed files with 21 additions and 8 deletions

View File

@ -110,7 +110,7 @@ public:
Int64 add(Int64 delta, bool create_if_need = false)
{
return add(delta, &CounterInFile::doNothing, create_if_need);
return add(delta, [](UInt64){}, create_if_need);
}
const std::string & getPath() const
@ -178,8 +178,6 @@ public:
private:
std::string path;
Poco::FastMutex mutex;
static void doNothing(UInt64 a) {}
};

View File

@ -31,6 +31,7 @@ namespace ErrorCodes
extern const int DIRECTORY_ALREADY_EXISTS;
extern const int TOO_MANY_UNEXPECTED_DATA_PARTS;
extern const int NO_SUCH_COLUMN_IN_TABLE;
extern const int TABLE_DIFFERS_TOO_MUCH;
}
/** Структура данных для *MergeTree движков.
@ -225,8 +226,6 @@ public:
};
static void doNothing(const String & name) {}
/** Подцепить таблицу с соответствующим именем, по соответствующему пути (с / на конце),
* (корректность имён и путей не проверяется)
* состоящую из указанных столбцов.
@ -249,7 +248,7 @@ public:
const MergeTreeSettings & settings_,
const String & log_name_,
bool require_part_metadata_,
BrokenPartCallback broken_part_callback_ = &MergeTreeData::doNothing);
BrokenPartCallback broken_part_callback_ = [](const String &){});
/// Загрузить множество кусков с данными с диска. Вызывается один раз - сразу после создания объекта.
void loadDataParts(bool skip_sanity_checks);

View File

@ -348,6 +348,7 @@ namespace ErrorCodes
extern const int METADATA_MISMATCH = 342;
extern const int INVALID_FUNCTION_GENUS = 343;
extern const int SUPPORT_IS_DISABLED = 344;
extern const int TABLE_DIFFERS_TOO_MUCH = 345;
extern const int KEEPER_EXCEPTION = 999;
extern const int POCO_EXCEPTION = 1000;

View File

@ -656,8 +656,23 @@ MergeTreeData::AlterDataPartTransactionPtr MergeTreeData::alterDataPart(
{
transaction->clear();
throw Exception("Suspiciously many (" + toString(transaction->rename_map.size())
+ ") files need to be modified in part " + part->name + ". Aborting just in case");
std::stringstream exception_message;
exception_message << "Suspiciously many (" << transaction->rename_map.size()
<< ") files (";
bool first = true;
for (const auto & from_to : transaction->rename_map)
{
if (!first)
exception_message << ", ";
exception_message << "from '" << from_to.first << "' to '" << from_to.second << "'";
first = false;
}
exception_message << ") need to be modified in part " << part->name << " of table at " << full_path << ". Aborting just in case. "
<< " If it is not an error, you could increase merge_tree/max_files_to_modify_in_alter_columns parameter in configuration file.";
throw Exception(exception_message.str(), ErrorCodes::TABLE_DIFFERS_TOO_MUCH);
}
DataPart::Checksums add_checksums;