ClickHouse/tests/queries/0_stateless/02995_forget_partition.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
2.0 KiB
Bash
Raw Normal View History

2024-03-13 15:25:58 +00:00
#!/usr/bin/env bash
# Tags: zookeeper, no-replicated-database
2024-02-20 18:55:45 +00:00
2024-03-13 15:25:58 +00:00
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
${CLICKHOUSE_CLIENT} --multiline -q """
2024-02-20 18:55:45 +00:00
drop table if exists forget_partition;
create table forget_partition
(
k UInt64,
d Date,
v String
)
engine = ReplicatedMergeTree('/test/02995/{database}/rmt', '1')
order by (k, d)
2024-06-03 15:33:35 +00:00
partition by toYYYYMMDD(d)
2024-06-03 17:22:23 +00:00
-- Reduce max_merge_selecting_sleep_ms and max_cleanup_delay_period to speed up the part being dropped from memory (RMT)
-- Same with old_parts_lifetime for SMT
SETTINGS old_parts_lifetime=5, merge_selecting_sleep_ms=1000, max_merge_selecting_sleep_ms=5000, cleanup_delay_period=3, max_cleanup_delay_period=5;
2024-02-20 18:55:45 +00:00
2024-02-20 23:57:10 +00:00
insert into forget_partition select number, '2024-01-01' + interval number day, randomString(20) from system.numbers limit 10;
2024-02-20 18:55:45 +00:00
alter table forget_partition drop partition '20240101';
alter table forget_partition drop partition '20240102';
2024-03-13 15:25:58 +00:00
"""
# DROP PARTITION do not wait for a part to be removed from memory due to possible concurrent SELECTs, so we have to do wait manually here
2024-06-03 17:22:23 +00:00
while [[ $(${CLICKHOUSE_CLIENT} -q "select count() from system.parts where database=currentDatabase() and table='forget_partition' and partition IN ('20240101', '20240102')") != 0 ]]; do sleep 1; done
2024-02-20 18:55:45 +00:00
${CLICKHOUSE_CLIENT} --multiline -q """
2024-02-20 18:55:45 +00:00
set allow_unrestricted_reads_from_keeper=1;
select '---before---';
select name from system.zookeeper where path = '/test/02995/' || currentDatabase() || '/rmt/block_numbers' order by name;
alter table forget_partition forget partition '20240103'; -- {serverError CANNOT_FORGET_PARTITION}
2024-02-21 15:11:50 +00:00
alter table forget_partition forget partition '20240203'; -- {serverError CANNOT_FORGET_PARTITION}
2024-02-20 18:55:45 +00:00
alter table forget_partition forget partition '20240101';
select '---after---';
select name from system.zookeeper where path = '/test/02995/' || currentDatabase() || '/rmt/block_numbers' order by name;
2024-02-20 18:56:39 +00:00
drop table forget_partition;
2024-03-13 15:25:58 +00:00
"""