Merge pull request #54467 from ClickHouse/drop-lost-part-log

Add a log message on replicated table drop
This commit is contained in:
Dmitry Novik 2023-09-12 15:59:18 +02:00 committed by GitHub
commit f730a003ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -981,6 +981,16 @@ void StorageReplicatedMergeTree::drop()
{
/// Session could expire, get it again
zookeeper = getZooKeeperIfTableShutDown();
auto lost_part_count_path = fs::path(zookeeper_path) / "lost_part_count";
Coordination::Stat lost_part_count_stat;
String lost_part_count_str;
if (zookeeper->tryGet(lost_part_count_path, lost_part_count_str, &lost_part_count_stat))
{
UInt64 lost_part_count = lost_part_count_str.empty() ? 0 : parse<UInt64>(lost_part_count_str);
if (lost_part_count > 0)
LOG_INFO(log, "Dropping table with non-zero lost_part_count equal to {}", lost_part_count);
}
dropReplica(zookeeper, zookeeper_path, replica_name, log, getSettings(), &has_metadata_in_zookeeper);
}
}

View File

@ -12,6 +12,8 @@ drop table rmt1;
system sync replica rmt2;
select lost_part_count from system.replicas where database = currentDatabase() and table = 'rmt2';
drop table rmt2;
SYSTEM FLUSH LOGS;
select count() from system.text_log where logger_name like '%' || currentDatabase() || '%' and message ilike '%table with non-zero lost_part_count equal to%';
create table rmt1 (d DateTime, n int) engine=ReplicatedMergeTree('/test/01165/{database}/rmt', '1') order by n partition by tuple();
@ -24,6 +26,8 @@ drop table rmt1;
system sync replica rmt2;
select lost_part_count from system.replicas where database = currentDatabase() and table = 'rmt2';
drop table rmt2;
SYSTEM FLUSH LOGS;
select count() from system.text_log where logger_name like '%' || currentDatabase() || '%' and message ilike '%table with non-zero lost_part_count equal to%';
create table rmt1 (n UInt8, m Int32, d Date, t DateTime) engine=ReplicatedMergeTree('/test/01165/{database}/rmt', '1') order by n partition by (n, m, d, t);