-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport #50026 to 23.4: Avoid deadlock when starting table in attach…
… thread of `ReplicatedMergeTree`
- Loading branch information
1 parent
f03e374
commit a005e61
Showing
5 changed files
with
94 additions
and
11 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.
6 changes: 6 additions & 0 deletions
6
tests/integration/test_replicated_table_attach/configs/config.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,6 @@ | ||
<clickhouse> | ||
<background_schedule_pool_size>1</background_schedule_pool_size> | ||
<merge_tree> | ||
<initialization_retry_period>5</initialization_retry_period> | ||
</merge_tree> | ||
</clickhouse> |
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,63 @@ | ||
import pytest | ||
|
||
from helpers.cluster import ClickHouseCluster | ||
from helpers.network import PartitionManager | ||
|
||
|
||
cluster = ClickHouseCluster(__file__) | ||
|
||
node = cluster.add_instance( | ||
"node", | ||
main_configs=["configs/config.xml"], | ||
with_zookeeper=True, | ||
stay_alive=True, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def started_cluster(): | ||
try: | ||
cluster.start() | ||
yield cluster | ||
|
||
finally: | ||
cluster.shutdown() | ||
|
||
|
||
def test_startup_with_small_bg_pool(started_cluster): | ||
node.query( | ||
"CREATE TABLE replicated_table (k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree('/clickhouse/replicated_table', 'r1') ORDER BY k" | ||
) | ||
|
||
node.query("INSERT INTO replicated_table VALUES(20, 30)") | ||
|
||
def assert_values(): | ||
assert node.query("SELECT * FROM replicated_table") == "20\t30\n" | ||
|
||
assert_values() | ||
node.restart_clickhouse(stop_start_wait_sec=10) | ||
assert_values() | ||
|
||
node.query("DROP TABLE replicated_table SYNC") | ||
|
||
|
||
def test_startup_with_small_bg_pool_partitioned(started_cluster): | ||
node.query( | ||
"CREATE TABLE replicated_table_partitioned (k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree('/clickhouse/replicated_table_partitioned', 'r1') ORDER BY k" | ||
) | ||
|
||
node.query("INSERT INTO replicated_table_partitioned VALUES(20, 30)") | ||
|
||
def assert_values(): | ||
assert node.query("SELECT * FROM replicated_table_partitioned") == "20\t30\n" | ||
|
||
assert_values() | ||
with PartitionManager() as pm: | ||
pm.drop_instance_zk_connections(node) | ||
node.restart_clickhouse(stop_start_wait_sec=20) | ||
assert_values() | ||
|
||
# check that we activate it in the end | ||
node.query_with_retry("INSERT INTO replicated_table_partitioned VALUES(20, 30)") | ||
|
||
node.query("DROP TABLE replicated_table_partitioned SYNC") |