From bb2f0a0893ed84419cf605369b46a6909b07a4c3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 23 May 2017 20:35:05 +0300 Subject: [PATCH] Always restore in case of corrupted query_log, part_log [#CLICKHOUSE-3020]. --- dbms/src/Interpreters/loadMetadata.cpp | 10 +++++++++- dbms/src/Interpreters/loadMetadata.h | 7 ++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dbms/src/Interpreters/loadMetadata.cpp b/dbms/src/Interpreters/loadMetadata.cpp index b51522ba87..b14c973857 100644 --- a/dbms/src/Interpreters/loadMetadata.cpp +++ b/dbms/src/Interpreters/loadMetadata.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -87,7 +88,14 @@ void loadMetadata(Context & context) else database_attach_query = "ATTACH DATABASE " + backQuoteIfNeed(database); - executeCreateQuery(database_attach_query, context, database, it->path(), thread_pool, has_force_restore_data_flag); + bool force_restore_data = has_force_restore_data_flag; + + /// For special system database, always restore data + /// to not fail on loading query_log and part_log tables, if they are corrupted. + if (database == "system") + force_restore_data = true; + + executeCreateQuery(database_attach_query, context, database, it->path(), thread_pool, force_restore_data); } thread_pool.wait(); diff --git a/dbms/src/Interpreters/loadMetadata.h b/dbms/src/Interpreters/loadMetadata.h index a9a29b9987..481b9cb1d7 100644 --- a/dbms/src/Interpreters/loadMetadata.h +++ b/dbms/src/Interpreters/loadMetadata.h @@ -1,15 +1,12 @@ #pragma once -#include - namespace DB { +class Context; -/** Загружает определения таблиц и БД и добавляет их в контекст. - */ +/// Load tables and add them to context. void loadMetadata(Context & context); - } -- GitLab