mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #53501 from azat/dist-flush_on_detach
Add ability to turn off flush of Distributed on DETACH/DROP/server shutdown
This commit is contained in:
commit
72b52250ea
@ -26,6 +26,7 @@ class ASTStorage;
|
||||
M(UInt64, monitor_split_batch_on_failure, 0, "Default - distributed_directory_monitor_split_batch_on_failure", 0) \
|
||||
M(Milliseconds, monitor_sleep_time_ms, 0, "Default - distributed_directory_monitor_sleep_time_ms", 0) \
|
||||
M(Milliseconds, monitor_max_sleep_time_ms, 0, "Default - distributed_directory_monitor_max_sleep_time_ms", 0) \
|
||||
M(Bool, flush_on_detach, true, "Flush data to remote nodes on DETACH/DROP/server shutdown", 0) \
|
||||
|
||||
DECLARE_SETTINGS_TRAITS(DistributedSettingsTraits, LIST_OF_DISTRIBUTED_SETTINGS)
|
||||
|
||||
|
@ -1438,6 +1438,12 @@ ActionLock StorageDistributed::getActionLock(StorageActionBlockType type)
|
||||
|
||||
void StorageDistributed::flushAndPrepareForShutdown()
|
||||
{
|
||||
if (!getDistributedSettingsRef().flush_on_detach)
|
||||
{
|
||||
LOG_INFO(log, "Skip flushing data (due to flush_on_detach=0)");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
flushClusterNodesAllData(getContext());
|
||||
|
@ -0,0 +1,27 @@
|
||||
-- { echoOn }
|
||||
|
||||
create table data (key Int) engine=Memory();
|
||||
create table dist (key Int) engine=Distributed(default, currentDatabase(), data);
|
||||
system stop distributed sends dist;
|
||||
-- check that FLUSH DISTRIBUTED does flushing anyway
|
||||
insert into dist values (1);
|
||||
select * from data;
|
||||
system flush distributed dist;
|
||||
select * from data;
|
||||
1
|
||||
truncate table data;
|
||||
-- check that flush_on_detach=1 by default
|
||||
insert into dist values (1);
|
||||
detach table dist;
|
||||
select * from data;
|
||||
1
|
||||
attach table dist;
|
||||
truncate table data;
|
||||
-- check flush_on_detach=0
|
||||
drop table dist;
|
||||
create table dist (key Int) engine=Distributed(default, currentDatabase(), data) settings flush_on_detach=0;
|
||||
system stop distributed sends dist;
|
||||
insert into dist values (1);
|
||||
detach table dist;
|
||||
select * from data;
|
||||
attach table dist;
|
@ -0,0 +1,33 @@
|
||||
set prefer_localhost_replica=0;
|
||||
|
||||
drop table if exists data;
|
||||
drop table if exists dist;
|
||||
|
||||
-- { echoOn }
|
||||
|
||||
create table data (key Int) engine=Memory();
|
||||
create table dist (key Int) engine=Distributed(default, currentDatabase(), data);
|
||||
system stop distributed sends dist;
|
||||
|
||||
-- check that FLUSH DISTRIBUTED does flushing anyway
|
||||
insert into dist values (1);
|
||||
select * from data;
|
||||
system flush distributed dist;
|
||||
select * from data;
|
||||
truncate table data;
|
||||
|
||||
-- check that flush_on_detach=1 by default
|
||||
insert into dist values (1);
|
||||
detach table dist;
|
||||
select * from data;
|
||||
attach table dist;
|
||||
truncate table data;
|
||||
|
||||
-- check flush_on_detach=0
|
||||
drop table dist;
|
||||
create table dist (key Int) engine=Distributed(default, currentDatabase(), data) settings flush_on_detach=0;
|
||||
system stop distributed sends dist;
|
||||
insert into dist values (1);
|
||||
detach table dist;
|
||||
select * from data;
|
||||
attach table dist;
|
Loading…
Reference in New Issue
Block a user