mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
Backport #72685 to 24.10: Fix flatten_nested when recovering a Replicated database
This commit is contained in:
parent
193f33fd38
commit
2b5b91d192
@ -1218,6 +1218,13 @@ void DatabaseReplicated::recoverLostReplica(const ZooKeeperPtr & current_zookeep
|
||||
query_context->setSetting("database_replicated_allow_explicit_uuid", 3);
|
||||
query_context->setSetting("database_replicated_allow_replicated_engine_arguments", 3);
|
||||
|
||||
/// We apply the flatten_nested setting after writing the CREATE query to the DDL log,
|
||||
/// but before writing metadata to ZooKeeper. So we have to apply the setting on secondary replicas, but not in recovery mode.
|
||||
/// Set it to false, so it will do nothing on recovery. The metadata in ZooKeeper should be used as is.
|
||||
/// Same for data_type_default_nullable.
|
||||
query_context->setSetting("flatten_nested", false);
|
||||
query_context->setSetting("data_type_default_nullable", false);
|
||||
|
||||
auto txn = std::make_shared<ZooKeeperMetadataTransaction>(current_zookeeper, zookeeper_path, false, "");
|
||||
query_context->initZooKeeperMetadataTransaction(txn);
|
||||
return query_context;
|
||||
|
@ -104,11 +104,27 @@ def test_flatten_nested(started_cluster):
|
||||
"CREATE MATERIALIZED VIEW create_replicated_table.mv ENGINE=ReplicatedMergeTree ORDER BY tuple() AS select d, cast([(k, toString(i32))] as Nested(a UInt64, b String)) from create_replicated_table.replicated_table"
|
||||
)
|
||||
|
||||
assert main_node.query(
|
||||
"show create create_replicated_table.mv"
|
||||
) == dummy_node.query("show create create_replicated_table.mv")
|
||||
main_node.query(
|
||||
"CREATE TABLE create_replicated_table.no_flatten (n Nested(a UInt64, b String)) ENGINE=ReplicatedMergeTree ORDER BY tuple();",
|
||||
settings={"flatten_nested": 0},
|
||||
)
|
||||
|
||||
snapshot_recovering_node.query(
|
||||
"CREATE DATABASE create_replicated_table ENGINE = Replicated('/test/create_replicated_table', 'shard1', 'replica3');"
|
||||
)
|
||||
snapshot_recovering_node.query(
|
||||
"SYSTEM SYNC DATABASE REPLICA create_replicated_table"
|
||||
)
|
||||
|
||||
for node in [dummy_node, snapshot_recovering_node]:
|
||||
for table in ["replicated_table", "mv", "no_flatten"]:
|
||||
assert main_node.query(
|
||||
f"show create create_replicated_table.{table}"
|
||||
) == node.query(f"show create create_replicated_table.{table}")
|
||||
|
||||
main_node.query("DROP DATABASE create_replicated_table SYNC")
|
||||
dummy_node.query("DROP DATABASE create_replicated_table SYNC")
|
||||
snapshot_recovering_node.query("DROP DATABASE create_replicated_table SYNC")
|
||||
|
||||
|
||||
def test_create_replicated_table(started_cluster):
|
||||
|
Loading…
Reference in New Issue
Block a user