mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fix crash when BACKUP & RESTORE are called without ON CLUSTER for replicated DB.
This commit is contained in:
parent
2a645bb187
commit
b1295311c9
@ -7,6 +7,7 @@
|
||||
#include <Backups/IBackupEntry.h>
|
||||
#include <Backups/IRestoreTask.h>
|
||||
#include <Backups/RestoreCoordinationDistributed.h>
|
||||
#include <Backups/RestoreCoordinationLocal.h>
|
||||
#include <Backups/formatTableNameOrTemporaryTableName.h>
|
||||
#include <Common/escapeForFileName.h>
|
||||
#include <Databases/IDatabase.h>
|
||||
@ -471,6 +472,8 @@ namespace
|
||||
{
|
||||
if (!restore_settings.coordination_zk_path.empty())
|
||||
restore_coordination = std::make_shared<RestoreCoordinationDistributed>(restore_settings.coordination_zk_path, [context=context] { return context->getZooKeeper(); });
|
||||
else
|
||||
restore_coordination = std::make_shared<RestoreCoordinationLocal>();
|
||||
}
|
||||
|
||||
/// Prepares internal structures for making tasks for restoring.
|
||||
|
@ -158,3 +158,17 @@ def test_different_tables_on_nodes():
|
||||
[[1, "Don\\'t"], [2, "count"], [3, "your"], [4, "chickens"]]
|
||||
)
|
||||
assert node2.query("SELECT * FROM tbl") == TSV([-333, -222, -111, 0, 111])
|
||||
|
||||
|
||||
def test_backup_restore_on_single_replica():
|
||||
node1.query("CREATE DATABASE mydb ON CLUSTER 'cluster' ENGINE=Replicated('/clickhouse/path/','{shard}','{replica}')")
|
||||
node1.query("CREATE TABLE mydb.test (`name` String, `value` UInt32) ENGINE = ReplicatedMergeTree ORDER BY value")
|
||||
node1.query("INSERT INTO mydb.test VALUES ('abc', 1), ('def', 2)")
|
||||
node1.query("INSERT INTO mydb.test VALUES ('ghi', 3)")
|
||||
|
||||
backup_name = new_backup_name()
|
||||
node1.query(f"BACKUP DATABASE mydb TO {backup_name}")
|
||||
|
||||
node1.query("DROP DATABASE mydb NO DELAY")
|
||||
|
||||
node1.query(f"RESTORE DATABASE mydb FROM {backup_name}")
|
||||
|
Loading…
Reference in New Issue
Block a user