mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #8176 from ClickHouse/fix_tmp_drop_relative_path
Fix loading of partially dropped table
This commit is contained in:
commit
efb916c556
@ -507,8 +507,10 @@ void DatabaseOnDisk::iterateMetadataFiles(const IDatabase & database, Poco::Logg
|
||||
const std::string object_name = dir_it.name().substr(0, dir_it.name().size() - strlen(tmp_drop_ext));
|
||||
if (Poco::File(database.getDataPath() + '/' + object_name).exists())
|
||||
{
|
||||
Poco::File(dir_it->path()).renameTo(object_name + ".sql");
|
||||
LOG_WARNING(log, "Object " << backQuote(object_name) << " was not dropped previously");
|
||||
/// TODO maybe complete table drop and remove all table data (including data on other volumes and metadata in ZK)
|
||||
Poco::File(dir_it->path()).renameTo(database.getMetadataPath() + object_name + ".sql");
|
||||
LOG_WARNING(log, "Object " << backQuote(object_name) << " was not dropped previously and will be restored");
|
||||
iterating_function(object_name + ".sql");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -0,0 +1,3 @@
|
||||
1
|
||||
2
|
||||
3
|
|
@ -0,0 +1 @@
|
||||
attach table should_be_dropped (n UInt8) engine = File(CSV)
|
@ -0,0 +1 @@
|
||||
attach table should_be_restored (n UInt8) engine = File(CSV)
|
@ -26,3 +26,11 @@ def test_sophisticated_default(started_cluster):
|
||||
instance.query("INSERT INTO sophisticated_default (c) VALUES (0)")
|
||||
assert instance.query("SELECT a, b, c FROM sophisticated_default") == "3\t9\t0\n"
|
||||
|
||||
|
||||
def test_partially_dropped_tables(started_cluster):
|
||||
instance = started_cluster.instances['dummy']
|
||||
assert instance.exec_in_container(['bash', '-c', 'cd / && find -name *.sql* | sort'], privileged=True, user='root') \
|
||||
== "./var/lib/clickhouse/metadata/default/should_be_restored.sql\n" \
|
||||
"./var/lib/clickhouse/metadata/default/sophisticated_default.sql\n"
|
||||
assert instance.query("SELECT n FROM should_be_restored") == "1\n2\n3\n"
|
||||
assert instance.query("SELECT count() FROM system.tables WHERE name='should_be_dropped'") == "0\n"
|
||||
|
Loading…
Reference in New Issue
Block a user