Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54368 from ClickHouse/fix_replacing_final_error
Fix logical error in vertical merge + replacing merge tree + optimize cleanup
- Loading branch information
Showing
7 changed files
with
69 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/queries/0_stateless/02861_replacing_merge_tree_with_cleanup.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
== Only last version remains after OPTIMIZE W/ CLEANUP == | ||
d1 5 0 | ||
d2 1 0 | ||
d3 1 0 | ||
d4 1 0 | ||
d5 1 0 | ||
d6 3 0 | ||
== OPTIMIZE W/ CLEANUP (remove d6) == | ||
d1 5 0 | ||
d2 1 0 | ||
d3 1 0 | ||
d4 1 0 | ||
d5 1 0 |
23 changes: 23 additions & 0 deletions
23
tests/queries/0_stateless/02861_replacing_merge_tree_with_cleanup.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
DROP TABLE IF EXISTS test; | ||
CREATE TABLE test (uid String, version UInt32, is_deleted UInt8) ENGINE = ReplacingMergeTree(version, is_deleted) Order by (uid) SETTINGS vertical_merge_algorithm_min_rows_to_activate = 1, | ||
vertical_merge_algorithm_min_columns_to_activate = 0, | ||
min_rows_for_wide_part = 1, | ||
min_bytes_for_wide_part = 1; | ||
|
||
-- Expect d6 to be version=3 is_deleted=false | ||
INSERT INTO test (*) VALUES ('d1', 1, 0), ('d1', 2, 1), ('d1', 3, 0), ('d1', 4, 1), ('d1', 5, 0), ('d2', 1, 0), ('d3', 1, 0), ('d4', 1, 0), ('d5', 1, 0), ('d6', 1, 0), ('d6', 3, 0); | ||
-- Insert previous version of 'd6' but only v=3 is_deleted=false will remain | ||
INSERT INTO test (*) VALUES ('d1', 1, 0), ('d1', 2, 1), ('d1', 3, 0), ('d1', 4, 1), ('d1', 5, 0), ('d2', 1, 0), ('d3', 1, 0), ('d4', 1, 0), ('d5', 1, 0), ('d6', 1, 0), ('d6', 2, 1); | ||
SELECT '== Only last version remains after OPTIMIZE W/ CLEANUP =='; | ||
OPTIMIZE TABLE test FINAL CLEANUP; | ||
select * from test order by uid; | ||
|
||
-- insert d6 v=3 is_deleted=true (timestamp more recent so this version should be the one take into acount) | ||
INSERT INTO test (*) VALUES ('d1', 1, 0), ('d1', 2, 1), ('d1', 3, 0), ('d1', 4, 1), ('d1', 5, 0), ('d2', 1, 0), ('d3', 1, 0), ('d4', 1, 0), ('d5', 1, 0), ('d6', 1, 0), ('d6', 3, 1); | ||
|
||
SELECT '== OPTIMIZE W/ CLEANUP (remove d6) =='; | ||
OPTIMIZE TABLE test FINAL CLEANUP; | ||
-- No d6 anymore | ||
select * from test order by uid; | ||
|
||
DROP TABLE IF EXISTS test; |