mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #18614 from CurtizJ/fix-empty-parts
Fix removing of empty parts in tables with old syntax
This commit is contained in:
commit
1bcdf37c36
@ -6155,7 +6155,7 @@ bool StorageReplicatedMergeTree::dropPart(
|
||||
/// DROP_RANGE with detach will move this part together with source parts to `detached/` dir.
|
||||
entry.type = LogEntry::DROP_RANGE;
|
||||
entry.source_replica = replica_name;
|
||||
entry.new_part_name = drop_part_info.getPartName();
|
||||
entry.new_part_name = getPartNamePossiblyFake(format_version, drop_part_info);
|
||||
entry.detach = detach;
|
||||
entry.create_time = time(nullptr);
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
<yandex>
|
||||
<merge_tree>
|
||||
<cleanup_delay_period>0</cleanup_delay_period>
|
||||
<cleanup_delay_period_random_add>0</cleanup_delay_period_random_add>
|
||||
</merge_tree>
|
||||
</yandex>
|
@ -0,0 +1,13 @@
|
||||
<yandex>
|
||||
<remote_servers>
|
||||
<test_cluster>
|
||||
<shard>
|
||||
<internal_replication>true</internal_replication>
|
||||
<replica>
|
||||
<host>node1</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
</shard>
|
||||
</test_cluster>
|
||||
</remote_servers>
|
||||
</yandex>
|
38
tests/integration/test_merge_tree_empty_parts/test.py
Normal file
38
tests/integration/test_merge_tree_empty_parts/test.py
Normal file
@ -0,0 +1,38 @@
|
||||
import pytest
|
||||
import helpers.client
|
||||
import helpers.cluster
|
||||
from helpers.test_tools import assert_eq_with_retry
|
||||
|
||||
|
||||
cluster = helpers.cluster.ClickHouseCluster(__file__)
|
||||
node1 = cluster.add_instance('node1', main_configs=['configs/remote_servers.xml', 'configs/cleanup_thread.xml'], with_zookeeper=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
yield cluster
|
||||
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
def test_empty_parts_alter_delete(started_cluster):
|
||||
node1.query("CREATE TABLE empty_parts_delete (d Date, key UInt64, value String) \
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/empty_parts_delete', 'r1', d, key, 8192)")
|
||||
|
||||
node1.query("INSERT INTO empty_parts_delete VALUES (toDate('2020-10-10'), 1, 'a')")
|
||||
node1.query("ALTER TABLE empty_parts_delete DELETE WHERE 1 SETTINGS mutations_sync = 2")
|
||||
|
||||
print(node1.query("SELECT count() FROM empty_parts_delete"))
|
||||
assert_eq_with_retry(node1, "SELECT count() FROM system.parts WHERE table = 'empty_parts_delete' AND active", "0")
|
||||
|
||||
def test_empty_parts_summing(started_cluster):
|
||||
node1.query("CREATE TABLE empty_parts_summing (d Date, key UInt64, value Int64) \
|
||||
ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/empty_parts_summing', 'r1', d, key, 8192)")
|
||||
|
||||
node1.query("INSERT INTO empty_parts_summing VALUES (toDate('2020-10-10'), 1, 1)")
|
||||
node1.query("INSERT INTO empty_parts_summing VALUES (toDate('2020-10-10'), 1, -1)")
|
||||
node1.query("OPTIMIZE TABLE empty_parts_summing FINAL")
|
||||
|
||||
assert_eq_with_retry(node1, "SELECT count() FROM system.parts WHERE table = 'empty_parts_summing' AND active", "0")
|
Loading…
Reference in New Issue
Block a user