-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug with inability to drop detached partition in replicated merge tree on top of S3 without zero copy #55309
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
eec64ba
Fix bug with inability to drop detached partition in replicated merge…
alesapin 041a9c8
Automatic style fix
robot-clickhouse aa130b7
Fix offsets bug
alesapin 77d96e6
Merge branch 'fix_redundant_check' of github.com:ClickHouse/ClickHous…
alesapin ec69b28
Black
alesapin 08f4621
Fix for write-once storages
alesapin 89294c0
Review fixes: make check consistent in all write functions
alesapin File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Empty file.
32 changes: 32 additions & 0 deletions
32
tests/integration/test_replicated_s3_zero_copy_drop_partition/configs/storage_conf.xml
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,32 @@ | ||
<clickhouse> | ||
<logger> | ||
<level>test</level> | ||
</logger> | ||
|
||
<storage_configuration> | ||
<disks> | ||
<s3> | ||
<type>s3</type> | ||
<endpoint>http://minio1:9001/root/data/</endpoint> | ||
<access_key_id>minio</access_key_id> | ||
<secret_access_key>minio123</secret_access_key> | ||
</s3> | ||
</disks> | ||
<policies> | ||
<default> | ||
<default> | ||
<disk>default</disk> | ||
</default> | ||
</default> | ||
<s3> | ||
<volumes> | ||
<main> | ||
<disk>s3</disk> | ||
<prefer_not_to_merge>False</prefer_not_to_merge> | ||
<perform_ttl_move_on_insert>True</perform_ttl_move_on_insert> | ||
</main> | ||
</volumes> | ||
</s3> | ||
</policies> | ||
</storage_configuration> | ||
</clickhouse> |
106 changes: 106 additions & 0 deletions
106
tests/integration/test_replicated_s3_zero_copy_drop_partition/test.py
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,106 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import logging | ||
import random | ||
import string | ||
import time | ||
|
||
import pytest | ||
from helpers.cluster import ClickHouseCluster | ||
import minio | ||
|
||
|
||
cluster = ClickHouseCluster(__file__) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def started_cluster(): | ||
try: | ||
cluster.add_instance( | ||
"node1", | ||
main_configs=["configs/storage_conf.xml"], | ||
with_minio=True, | ||
with_zookeeper=True, | ||
) | ||
cluster.start() | ||
|
||
yield cluster | ||
finally: | ||
cluster.shutdown() | ||
|
||
|
||
def get_objects_in_data_path(): | ||
minio = cluster.minio_client | ||
objects = minio.list_objects(cluster.minio_bucket, "data/", recursive=True) | ||
return [obj.object_name for obj in objects] | ||
|
||
|
||
def test_drop_after_fetch(started_cluster): | ||
node1 = cluster.instances["node1"] | ||
|
||
node1.query( | ||
""" | ||
CREATE TABLE test_local(c1 Int8, c2 Date) ENGINE = ReplicatedMergeTree('/test/tables/shard/test_local', '1') PARTITION BY c2 ORDER BY c2 | ||
""" | ||
) | ||
node1.query( | ||
""" | ||
CREATE TABLE test_s3(c1 Int8, c2 Date) ENGINE = ReplicatedMergeTree('/test/tables/shard/test_s3', '1') PARTITION BY c2 ORDER BY c2 SETTINGS storage_policy = 's3', allow_remote_fs_zero_copy_replication=0 | ||
""" | ||
) | ||
|
||
node1.query("INSERT INTO test_local VALUES (1, '2023-10-04'), (2, '2023-10-04')") | ||
|
||
assert node1.query("SELECT count() FROM test_local") == "2\n" | ||
|
||
objects_before = get_objects_in_data_path() | ||
node1.query( | ||
"ALTER TABLE test_s3 FETCH PARTITION '2023-10-04' FROM '/test/tables/shard/test_local'" | ||
) | ||
|
||
node1.query( | ||
"ALTER TABLE test_s3 DROP DETACHED PARTITION '2023-10-04' SETTINGS allow_drop_detached = 1" | ||
) | ||
|
||
objects_after = get_objects_in_data_path() | ||
|
||
assert objects_before == objects_after | ||
|
||
|
||
def test_drop_complex_columns(started_cluster): | ||
start_objects = get_objects_in_data_path() | ||
print("Objects before", start_objects) | ||
node1 = cluster.instances["node1"] | ||
node1.query( | ||
""" | ||
CREATE TABLE test_s3_complex_types( | ||
c1 Int8, | ||
c2 Date, | ||
`c3.k` Array(String), | ||
`c3.v1` Array(Int64), | ||
`c3.v3` Array(Int64), | ||
`c3.v4` Array(Int64) | ||
) ENGINE = MergeTree | ||
order by (c1,c2) SETTINGS storage_policy = 's3', | ||
min_bytes_for_wide_part=1, | ||
vertical_merge_algorithm_min_rows_to_activate=1, | ||
vertical_merge_algorithm_min_columns_to_activate=1;""" | ||
) | ||
|
||
node1.query( | ||
"insert into test_s3_complex_types values(1,toDate('2020-10-01'), ['a','b'], [1,2], [3,4], [5,6])" | ||
) | ||
|
||
node1.query( | ||
"insert into test_s3_complex_types values(1,toDate('2020-10-01'), ['a','b'], [7,8], [9,10], [11,12])" | ||
) | ||
|
||
print("Objects in insert", get_objects_in_data_path()) | ||
node1.query("optimize table test_s3_complex_types final") | ||
|
||
print("Objects in optimize", get_objects_in_data_path()) | ||
|
||
node1.query("DROP TABLE test_s3_complex_types SYNC") | ||
end_objects = get_objects_in_data_path() | ||
print("Objects after drop", end_objects) | ||
assert start_objects == end_objects |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need such changes in
DiskObjectStorageTransaction::writeFileUsingBlobWritingFunction
also?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes, let's do!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also
Unfreezer::removeFreezedPart
has similar branchif (disk->supportZeroCopyReplication())
. Maybe it is worth to fix it too.