forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 17
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 ClickHouse#9652 from ClickHouse/fix_compatibility_…
…for_mutations Fix compatibility in replication
- Loading branch information
Showing
4 changed files
with
91 additions
and
5 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
Empty file.
74 changes: 74 additions & 0 deletions
74
dbms/tests/integration/test_version_update_after_mutation/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,74 @@ | ||
import pytest | ||
import time | ||
|
||
from helpers.cluster import ClickHouseCluster | ||
from helpers.test_tools import assert_eq_with_retry | ||
|
||
cluster = ClickHouseCluster(__file__) | ||
|
||
node1 = cluster.add_instance('node1', with_zookeeper=True, image='yandex/clickhouse-server:20.1.6.3', with_installed_binary=True, stay_alive=True) | ||
node2 = cluster.add_instance('node2', with_zookeeper=True, image='yandex/clickhouse-server:20.1.6.3', with_installed_binary=True, stay_alive=True) | ||
node3 = cluster.add_instance('node3', with_zookeeper=True, image='yandex/clickhouse-server:20.1.6.3', with_installed_binary=True, stay_alive=True) | ||
|
||
@pytest.fixture(scope="module") | ||
def start_cluster(): | ||
try: | ||
cluster.start() | ||
|
||
yield cluster | ||
finally: | ||
cluster.shutdown() | ||
|
||
|
||
def test_mutate_and_upgrade(start_cluster): | ||
for node in [node1, node2]: | ||
node.query("CREATE TABLE mt (EventDate Date, id UInt64) ENGINE ReplicatedMergeTree('/clickhouse/tables/t', '{}') ORDER BY tuple()".format(node.name)) | ||
|
||
node1.query("INSERT INTO mt VALUES ('2020-02-13', 1), ('2020-02-13', 2);") | ||
|
||
node1.query("ALTER TABLE mt DELETE WHERE id = 2", settings={"mutations_sync": "2"}) | ||
node2.query("SYSTEM SYNC REPLICA mt", timeout=5) | ||
|
||
node1.restart_with_latest_version() | ||
node2.restart_with_latest_version() | ||
|
||
node2.query("INSERT INTO mt VALUES ('2020-02-13', 3);") | ||
|
||
node1.query("SYSTEM SYNC REPLICA mt", timeout=5) | ||
|
||
assert node1.query("SELECT COUNT() FROM mt") == "2\n" | ||
assert node2.query("SELECT COUNT() FROM mt") == "2\n" | ||
|
||
node1.query("INSERT INTO mt VALUES ('2020-02-13', 4);") | ||
|
||
node2.query("SYSTEM SYNC REPLICA mt", timeout=5) | ||
|
||
assert node1.query("SELECT COUNT() FROM mt") == "3\n" | ||
assert node2.query("SELECT COUNT() FROM mt") == "3\n" | ||
|
||
node2.query("ALTER TABLE mt DELETE WHERE id = 3", settings={"mutations_sync": "2"}) | ||
|
||
node1.query("SYSTEM SYNC REPLICA mt", timeout=5) | ||
|
||
assert node1.query("SELECT COUNT() FROM mt") == "2\n" | ||
assert node2.query("SELECT COUNT() FROM mt") == "2\n" | ||
|
||
node1.query("ALTER TABLE mt MODIFY COLUMN id String DEFAULT '0'", settings={"replication_alter_partitions_sync": "2"}) | ||
|
||
node2.query("OPTIMIZE TABLE mt FINAL") | ||
|
||
assert node1.query("SELECT id FROM mt") == "1\n4\n" | ||
assert node2.query("SELECT id FROM mt") == "1\n4\n" | ||
|
||
|
||
def test_upgrade_while_mutation(start_cluster): | ||
node3.query("CREATE TABLE mt1 (EventDate Date, id UInt64) ENGINE ReplicatedMergeTree('/clickhouse/tables/t1', 'node3') ORDER BY tuple()") | ||
|
||
node3.query("INSERT INTO mt1 select '2020-02-13', number from numbers(100000)") | ||
|
||
node3.query("SYSTEM STOP MERGES") | ||
node3.query("ALTER TABLE mt1 DELETE WHERE id % 2 == 0") | ||
|
||
node3.restart_with_latest_version() | ||
|
||
assert_eq_with_retry(node3, "SELECT COUNT() from mt1", "50000\n") |