#include #include #include #include #include #include #include namespace DB { ColumnsDescription StorageSystemErrors::getColumnsDescription() { return ColumnsDescription { { "name", std::make_shared(), "Name of the error (errorCodeToName)."}, { "code", std::make_shared(), "Code number of the error."}, { "value", std::make_shared(), "The number of times this error happened."}, { "last_error_time", std::make_shared(), "The time when the last error happened."}, { "last_error_message", std::make_shared(), "Message for the last error."}, { "last_error_trace", std::make_shared(std::make_shared()), "A stack trace that represents a list of physical addresses where the called methods are stored."}, { "remote", std::make_shared(), "Remote exception (i.e. received during one of the distributed queries)."}, }; } void StorageSystemErrors::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const { auto add_row = [&](std::string_view name, size_t code, const auto & error, bool remote) { if (error.count || context->getSettingsRef().system_events_show_zero_values) { size_t col_num = 0; res_columns[col_num++]->insert(name); res_columns[col_num++]->insert(code); res_columns[col_num++]->insert(error.count); res_columns[col_num++]->insert(error.error_time_ms / 1000); res_columns[col_num++]->insert(error.message); { Array trace_array; trace_array.reserve(error.trace.size()); for (size_t i = 0; i < error.trace.size(); ++i) trace_array.emplace_back(reinterpret_cast(error.trace[i])); res_columns[col_num++]->insert(trace_array); } res_columns[col_num++]->insert(remote); } }; for (size_t i = 0, end = ErrorCodes::end(); i < end; ++i) { const auto & error = ErrorCodes::values[i].get(); std::string_view name = ErrorCodes::getName(static_cast(i)); if (name.empty()) continue; add_row(name, i, error.local, /* remote= */ false); add_row(name, i, error.remote, /* remote= */ true); } } }