mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Reset part level upon attach from disk on MergeTree (#61536)
* hackish change to check how CI reacts * remove unnecessary renameTo * introduce separate metho * remove unused arg * rename meth od * add simple test * add current database * set mutations sync * Update tests/queries/0_stateless/03013_test_part_level_is_reset_attach_from_disk_mt.sql --------- Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com> Co-authored-by: János Benjamin Antal <benjamin.antal@clickhouse.com>
This commit is contained in:
parent
2f382ac8a8
commit
2ed53e309b
@ -2042,7 +2042,7 @@ PartitionCommandsResultInfo StorageMergeTree::attachPartition(
|
||||
MergeTreeData::Transaction transaction(*this, local_context->getCurrentTransaction().get());
|
||||
{
|
||||
auto lock = lockParts();
|
||||
fillNewPartName(loaded_parts[i], lock);
|
||||
fillNewPartNameAndResetLevel(loaded_parts[i], lock);
|
||||
renameTempPartAndAdd(loaded_parts[i], transaction, lock);
|
||||
transaction.commit(&lock);
|
||||
}
|
||||
@ -2482,4 +2482,12 @@ void StorageMergeTree::fillNewPartName(MutableDataPartPtr & part, DataPartsLock
|
||||
part->setName(part->getNewName(part->info));
|
||||
}
|
||||
|
||||
void StorageMergeTree::fillNewPartNameAndResetLevel(MutableDataPartPtr & part, DataPartsLock &)
|
||||
{
|
||||
part->info.min_block = part->info.max_block = increment.get();
|
||||
part->info.mutation = 0;
|
||||
part->info.level = 0;
|
||||
part->setName(part->getNewName(part->info));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -260,6 +260,7 @@ private:
|
||||
std::set<String> * mutation_ids = nullptr, bool from_another_mutation = false) const;
|
||||
|
||||
void fillNewPartName(MutableDataPartPtr & part, DataPartsLock & lock);
|
||||
void fillNewPartNameAndResetLevel(MutableDataPartPtr & part, DataPartsLock & lock);
|
||||
|
||||
void startBackgroundMovesIfNeeded() override;
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
-- {echoOn}
|
||||
DROP TABLE IF EXISTS test;
|
||||
CREATE TABLE test (a Int) ENGINE = MergeTree ORDER BY tuple();
|
||||
INSERT INTO test VALUES (1), (2), (3);
|
||||
OPTIMIZE TABLE test FINAL;
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
||||
all_1_1_1
|
||||
ALTER TABLE test DETACH PART 'all_1_1_1';
|
||||
ALTER TABLE test ATTACH PART 'all_1_1_1';
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
||||
all_2_2_0
|
||||
-- Same as above, but with attach partition (different code path, should be tested as well)
|
||||
DROP TABLE IF EXISTS test;
|
||||
CREATE TABLE test (a Int) ENGINE = MergeTree ORDER BY tuple();
|
||||
INSERT INTO test VALUES (1), (2), (3);
|
||||
OPTIMIZE TABLE test FINAL;
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
||||
all_1_1_1
|
||||
ALTER TABLE test DETACH PART 'all_1_1_1';
|
||||
ALTER TABLE test ATTACH PARTITION tuple();
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
||||
all_2_2_0
|
@ -0,0 +1,21 @@
|
||||
-- Tags: no-shared-merge-tree
|
||||
SET alter_sync = 2;
|
||||
-- {echoOn}
|
||||
DROP TABLE IF EXISTS test;
|
||||
CREATE TABLE test (a Int) ENGINE = MergeTree ORDER BY tuple();
|
||||
INSERT INTO test VALUES (1), (2), (3);
|
||||
OPTIMIZE TABLE test FINAL;
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
||||
ALTER TABLE test DETACH PART 'all_1_1_1';
|
||||
ALTER TABLE test ATTACH PART 'all_1_1_1';
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
||||
|
||||
-- Same as above, but with attach partition (different code path, should be tested as well)
|
||||
DROP TABLE IF EXISTS test;
|
||||
CREATE TABLE test (a Int) ENGINE = MergeTree ORDER BY tuple();
|
||||
INSERT INTO test VALUES (1), (2), (3);
|
||||
OPTIMIZE TABLE test FINAL;
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
||||
ALTER TABLE test DETACH PART 'all_1_1_1';
|
||||
ALTER TABLE test ATTACH PARTITION tuple();
|
||||
SELECT part_name FROM system.parts where table='test' and active and database = currentDatabase();
|
Loading…
Reference in New Issue
Block a user