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 inconsistent parts after clone replica #6523
Merged
alexey-milovidov
merged 3 commits into
master
from
fix_inconsistent_parts_after_clone_replica
Aug 19, 2019
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Empty file.
19 changes: 19 additions & 0 deletions
19
dbms/tests/integration/test_consistent_parts_after_clone_replica/configs/remote_servers.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,19 @@ | ||
<yandex> | ||
<remote_servers> | ||
<test_cluster> | ||
<shard> | ||
<internal_replication>true</internal_replication> | ||
<replica> | ||
<default_database>shard_0</default_database> | ||
<host>node1</host> | ||
<port>9000</port> | ||
</replica> | ||
<replica> | ||
<default_database>shard_0</default_database> | ||
<host>node2</host> | ||
<port>9000</port> | ||
</replica> | ||
</shard> | ||
</test_cluster> | ||
</remote_servers> | ||
</yandex> |
60 changes: 60 additions & 0 deletions
60
dbms/tests/integration/test_consistent_parts_after_clone_replica/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,60 @@ | ||
import pytest | ||
|
||
from helpers.cluster import ClickHouseCluster | ||
from helpers.network import PartitionManager | ||
from helpers.test_tools import assert_eq_with_retry | ||
|
||
|
||
def fill_nodes(nodes, shard): | ||
for node in nodes: | ||
node.query( | ||
''' | ||
CREATE DATABASE test; | ||
CREATE TABLE test_table(date Date, id UInt32) | ||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/test{shard}/replicated', '{replica}') | ||
ORDER BY id PARTITION BY toYYYYMM(date) | ||
SETTINGS min_replicated_logs_to_keep=3, max_replicated_logs_to_keep=5, cleanup_delay_period=0, cleanup_delay_period_random_add=0; | ||
'''.format(shard=shard, replica=node.name)) | ||
|
||
|
||
cluster = ClickHouseCluster(__file__) | ||
node1 = cluster.add_instance('node1', main_configs=['configs/remote_servers.xml'], with_zookeeper=True) | ||
node2 = cluster.add_instance('node2', main_configs=['configs/remote_servers.xml'], with_zookeeper=True) | ||
|
||
@pytest.fixture(scope="module") | ||
def start_cluster(): | ||
try: | ||
cluster.start() | ||
fill_nodes([node1, node2], 1) | ||
yield cluster | ||
except Exception as ex: | ||
print ex | ||
finally: | ||
cluster.shutdown() | ||
|
||
|
||
def test_inconsistent_parts_if_drop_while_replica_not_active(start_cluster): | ||
with PartitionManager() as pm: | ||
# insert into all replicas | ||
for i in range(50): | ||
node1.query("INSERT INTO test_table VALUES ('2019-08-16', {})".format(i)) | ||
assert_eq_with_retry(node2, "SELECT count(*) FROM test_table", node1.query("SELECT count(*) FROM test_table")) | ||
|
||
# disable network on the first replica | ||
pm.partition_instances(node1, node2) | ||
pm.drop_instance_zk_connections(node1) | ||
|
||
# drop all parts on the second replica | ||
node2.query_with_retry("ALTER TABLE test_table DROP PARTITION 201908") | ||
assert_eq_with_retry(node2, "SELECT count(*) FROM test_table", "0") | ||
|
||
# insert into the second replica | ||
# DROP_RANGE will be removed from the replication log and the first replica will be lost | ||
for i in range(50): | ||
node2.query("INSERT INTO test_table VALUES ('2019-08-16', {})".format(50 + i)) | ||
|
||
# the first replica will be cloned from the second | ||
pm.heal_all() | ||
assert_eq_with_retry(node1, "SELECT count(*) FROM test_table", node2.query("SELECT count(*) FROM test_table")) | ||
|
||
|
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.
Ok. But all usages of this function look suspicious because result is not checked.