mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-01 03:52:15 +00:00
Merge pull request #58178 from chhetripradeep/add-base-backup-name-to-system-tables
Add base backup name to system.backups and system.backup_log tables
This commit is contained in:
commit
00fa9085b1
@ -17,6 +17,9 @@ struct BackupOperationInfo
|
|||||||
/// Operation name, a string like "Disk('backups', 'my_backup')"
|
/// Operation name, a string like "Disk('backups', 'my_backup')"
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
/// Base Backup Operation name, a string like "Disk('backups', 'my_base_backup')"
|
||||||
|
String base_backup_name;
|
||||||
|
|
||||||
/// This operation is internal and should not be shown in system.backups
|
/// This operation is internal and should not be shown in system.backups
|
||||||
bool internal = false;
|
bool internal = false;
|
||||||
|
|
||||||
|
@ -394,9 +394,13 @@ OperationID BackupsWorker::startMakingBackup(const ASTPtr & query, const Context
|
|||||||
|
|
||||||
auto backup_info = BackupInfo::fromAST(*backup_query->backup_name);
|
auto backup_info = BackupInfo::fromAST(*backup_query->backup_name);
|
||||||
String backup_name_for_logging = backup_info.toStringForLogging();
|
String backup_name_for_logging = backup_info.toStringForLogging();
|
||||||
|
String base_backup_name;
|
||||||
|
if (backup_settings.base_backup_info)
|
||||||
|
base_backup_name = backup_settings.base_backup_info->toString();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
addInfo(backup_id, backup_name_for_logging, backup_settings.internal, BackupStatus::CREATING_BACKUP);
|
addInfo(backup_id, backup_name_for_logging, base_backup_name, backup_settings.internal, BackupStatus::CREATING_BACKUP);
|
||||||
|
|
||||||
/// Prepare context to use.
|
/// Prepare context to use.
|
||||||
ContextPtr context_in_use = context;
|
ContextPtr context_in_use = context;
|
||||||
@ -745,8 +749,11 @@ OperationID BackupsWorker::startRestoring(const ASTPtr & query, ContextMutablePt
|
|||||||
{
|
{
|
||||||
auto backup_info = BackupInfo::fromAST(*restore_query->backup_name);
|
auto backup_info = BackupInfo::fromAST(*restore_query->backup_name);
|
||||||
String backup_name_for_logging = backup_info.toStringForLogging();
|
String backup_name_for_logging = backup_info.toStringForLogging();
|
||||||
|
String base_backup_name;
|
||||||
|
if (restore_settings.base_backup_info)
|
||||||
|
base_backup_name = restore_settings.base_backup_info->toString();
|
||||||
|
|
||||||
addInfo(restore_id, backup_name_for_logging, restore_settings.internal, BackupStatus::RESTORING);
|
addInfo(restore_id, backup_name_for_logging, base_backup_name, restore_settings.internal, BackupStatus::RESTORING);
|
||||||
|
|
||||||
/// Prepare context to use.
|
/// Prepare context to use.
|
||||||
ContextMutablePtr context_in_use = context;
|
ContextMutablePtr context_in_use = context;
|
||||||
@ -1005,11 +1012,12 @@ void BackupsWorker::restoreTablesData(const OperationID & restore_id, BackupPtr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BackupsWorker::addInfo(const OperationID & id, const String & name, bool internal, BackupStatus status)
|
void BackupsWorker::addInfo(const OperationID & id, const String & name, const String & base_backup_name, bool internal, BackupStatus status)
|
||||||
{
|
{
|
||||||
BackupOperationInfo info;
|
BackupOperationInfo info;
|
||||||
info.id = id;
|
info.id = id;
|
||||||
info.name = name;
|
info.name = name;
|
||||||
|
info.base_backup_name = base_backup_name;
|
||||||
info.internal = internal;
|
info.internal = internal;
|
||||||
info.status = status;
|
info.status = status;
|
||||||
info.start_time = std::chrono::system_clock::now();
|
info.start_time = std::chrono::system_clock::now();
|
||||||
|
@ -83,7 +83,7 @@ private:
|
|||||||
/// Run data restoring tasks which insert data to tables.
|
/// Run data restoring tasks which insert data to tables.
|
||||||
void restoreTablesData(const BackupOperationID & restore_id, BackupPtr backup, DataRestoreTasks && tasks, ThreadPool & thread_pool);
|
void restoreTablesData(const BackupOperationID & restore_id, BackupPtr backup, DataRestoreTasks && tasks, ThreadPool & thread_pool);
|
||||||
|
|
||||||
void addInfo(const BackupOperationID & id, const String & name, bool internal, BackupStatus status);
|
void addInfo(const BackupOperationID & id, const String & name, const String & base_backup_name, bool internal, BackupStatus status);
|
||||||
void setStatus(const BackupOperationID & id, BackupStatus status, bool throw_if_error = true);
|
void setStatus(const BackupOperationID & id, BackupStatus status, bool throw_if_error = true);
|
||||||
void setStatusSafe(const String & id, BackupStatus status) { setStatus(id, status, false); }
|
void setStatusSafe(const String & id, BackupStatus status) { setStatus(id, status, false); }
|
||||||
void setNumFilesAndSize(const BackupOperationID & id, size_t num_files, UInt64 total_size, size_t num_entries,
|
void setNumFilesAndSize(const BackupOperationID & id, size_t num_files, UInt64 total_size, size_t num_entries,
|
||||||
|
@ -27,6 +27,7 @@ NamesAndTypesList BackupLogElement::getNamesAndTypes()
|
|||||||
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
|
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
|
||||||
{"id", std::make_shared<DataTypeString>()},
|
{"id", std::make_shared<DataTypeString>()},
|
||||||
{"name", std::make_shared<DataTypeString>()},
|
{"name", std::make_shared<DataTypeString>()},
|
||||||
|
{"base_backup_name", std::make_shared<DataTypeString>()},
|
||||||
{"status", std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues())},
|
{"status", std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues())},
|
||||||
{"error", std::make_shared<DataTypeString>()},
|
{"error", std::make_shared<DataTypeString>()},
|
||||||
{"start_time", std::make_shared<DataTypeDateTime>()},
|
{"start_time", std::make_shared<DataTypeDateTime>()},
|
||||||
@ -49,6 +50,7 @@ void BackupLogElement::appendToBlock(MutableColumns & columns) const
|
|||||||
columns[i++]->insert(event_time_usec);
|
columns[i++]->insert(event_time_usec);
|
||||||
columns[i++]->insert(info.id);
|
columns[i++]->insert(info.id);
|
||||||
columns[i++]->insert(info.name);
|
columns[i++]->insert(info.name);
|
||||||
|
columns[i++]->insert(info.base_backup_name);
|
||||||
columns[i++]->insert(static_cast<Int8>(info.status));
|
columns[i++]->insert(static_cast<Int8>(info.status));
|
||||||
columns[i++]->insert(info.error_message);
|
columns[i++]->insert(info.error_message);
|
||||||
columns[i++]->insert(static_cast<UInt32>(std::chrono::system_clock::to_time_t(info.start_time)));
|
columns[i++]->insert(static_cast<UInt32>(std::chrono::system_clock::to_time_t(info.start_time)));
|
||||||
|
@ -20,6 +20,7 @@ NamesAndTypesList StorageSystemBackups::getNamesAndTypes()
|
|||||||
NamesAndTypesList names_and_types{
|
NamesAndTypesList names_and_types{
|
||||||
{"id", std::make_shared<DataTypeString>()},
|
{"id", std::make_shared<DataTypeString>()},
|
||||||
{"name", std::make_shared<DataTypeString>()},
|
{"name", std::make_shared<DataTypeString>()},
|
||||||
|
{"base_backup_name", std::make_shared<DataTypeString>()},
|
||||||
{"status", std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues())},
|
{"status", std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues())},
|
||||||
{"error", std::make_shared<DataTypeString>()},
|
{"error", std::make_shared<DataTypeString>()},
|
||||||
{"start_time", std::make_shared<DataTypeDateTime>()},
|
{"start_time", std::make_shared<DataTypeDateTime>()},
|
||||||
@ -42,6 +43,7 @@ void StorageSystemBackups::fillData(MutableColumns & res_columns, ContextPtr con
|
|||||||
size_t column_index = 0;
|
size_t column_index = 0;
|
||||||
auto & column_id = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
auto & column_id = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||||
auto & column_name = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
auto & column_name = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||||
|
auto & column_base_backup_name = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||||
auto & column_status = assert_cast<ColumnInt8 &>(*res_columns[column_index++]);
|
auto & column_status = assert_cast<ColumnInt8 &>(*res_columns[column_index++]);
|
||||||
auto & column_error = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
auto & column_error = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||||
auto & column_start_time = assert_cast<ColumnUInt32 &>(*res_columns[column_index++]);
|
auto & column_start_time = assert_cast<ColumnUInt32 &>(*res_columns[column_index++]);
|
||||||
@ -59,6 +61,7 @@ void StorageSystemBackups::fillData(MutableColumns & res_columns, ContextPtr con
|
|||||||
{
|
{
|
||||||
column_id.insertData(info.id.data(), info.id.size());
|
column_id.insertData(info.id.data(), info.id.size());
|
||||||
column_name.insertData(info.name.data(), info.name.size());
|
column_name.insertData(info.name.data(), info.name.size());
|
||||||
|
column_base_backup_name.insertData(info.base_backup_name.data(), info.base_backup_name.size());
|
||||||
column_status.insertValue(static_cast<Int8>(info.status));
|
column_status.insertValue(static_cast<Int8>(info.status));
|
||||||
column_error.insertData(info.error_message.data(), info.error_message.size());
|
column_error.insertData(info.error_message.data(), info.error_message.size());
|
||||||
column_start_time.insertValue(static_cast<UInt32>(std::chrono::system_clock::to_time_t(info.start_time)));
|
column_start_time.insertValue(static_cast<UInt32>(std::chrono::system_clock::to_time_t(info.start_time)));
|
||||||
|
Loading…
Reference in New Issue
Block a user