2023-04-06 19:07:53 +00:00
#!/usr/bin/env bash
2024-10-29 16:41:18 +00:00
# Tags: long, no-tsan, no-debug, no-asan, no-msan, no-ubsan, no-parallel, no-shared-merge-tree
# no-shared-merge-tree -- this test is too slow
2023-04-06 19:07:53 +00:00
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
# shellcheck source=../shell_config.sh
. " $CURDIR " /../shell_config.sh
2023-06-25 06:48:31 +00:00
# "max_parts_to_merge_at_once = 1" prevents merges to start in background before our own OPTIMIZE FINAL
2024-07-29 20:06:55 +00:00
$CLICKHOUSE_CLIENT -q "
2023-07-06 01:43:59 +00:00
drop table if exists many_mutations;
create table many_mutations ( x UInt32, y UInt32) engine = MergeTree order by x settings number_of_mutations_to_delay = 0, number_of_mutations_to_throw = 0, max_parts_to_merge_at_once = 1;
insert into many_mutations select number, number + 1 from numbers( 2000) ;
system stop merges many_mutations;
"
2023-04-06 19:07:53 +00:00
$CLICKHOUSE_CLIENT -q "select count() from many_mutations"
job( )
{
for i in { 1..1000}
do
2023-07-06 01:43:59 +00:00
echo " alter table many_mutations delete where y = ${ i } * 2 settings mutations_sync = 0; "
2024-07-29 20:06:55 +00:00
done | $CLICKHOUSE_CLIENT
2023-04-06 19:07:53 +00:00
}
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
job &
wait
2023-08-28 15:42:10 +00:00
# truncate before drop, avoid removing all the mutations (it's slow) in DatabaseCatalog's thread (may affect other tests)
2024-07-29 20:06:55 +00:00
$CLICKHOUSE_CLIENT -q "
2023-07-06 01:43:59 +00:00
select count( ) from system.mutations where database = currentDatabase( ) and table = 'many_mutations' and not is_done;
system start merges many_mutations;
optimize table many_mutations final SETTINGS optimize_throw_if_noop = 1;
2024-07-18 15:45:52 +00:00
alter table many_mutations update y = y + 1 where 1 settings mutations_sync = 2;
2023-07-06 01:43:59 +00:00
system flush logs;
select count( ) from system.mutations where database = currentDatabase( ) and table = 'many_mutations' and not is_done;
select count( ) from many_mutations;
select * from system.part_log where database = currentDatabase( ) and table = = 'many_mutations' and peak_memory_usage > 1e9;
2023-08-28 15:42:10 +00:00
truncate table many_mutations;
2023-07-06 01:43:59 +00:00
drop table many_mutations;
"