Skip to content
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

add zookeeper name in system.replicas #48549

Merged
merged 2 commits into from Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Storages/MergeTree/ReplicatedTableStatus.h
Expand Up @@ -16,6 +16,7 @@ struct ReplicatedTableStatus

ReplicatedMergeTreeQueue::Status queue;
UInt32 parts_to_check;
String zookeeper_name;
String zookeeper_path;
String replica_name;
String replica_path;
Expand Down
1 change: 1 addition & 0 deletions src/Storages/StorageReplicatedMergeTree.cpp
Expand Up @@ -5969,6 +5969,7 @@ void StorageReplicatedMergeTree::getStatus(ReplicatedTableStatus & res, bool wit
/// NOTE: consider convert to UInt64
res.parts_to_check = static_cast<UInt32>(part_check_thread.size());

res.zookeeper_name = zookeeper_name;
res.zookeeper_path = zookeeper_path;
res.replica_name = replica_name;
res.replica_path = replica_path;
Expand Down
2 changes: 2 additions & 0 deletions src/Storages/System/StorageSystemReplicas.cpp
Expand Up @@ -39,6 +39,7 @@ StorageSystemReplicas::StorageSystemReplicas(const StorageID & table_id_)
{ "is_session_expired", std::make_shared<DataTypeUInt8>() },
{ "future_parts", std::make_shared<DataTypeUInt32>() },
{ "parts_to_check", std::make_shared<DataTypeUInt32>() },
{ "zookeeper_name", std::make_shared<DataTypeString>() },
{ "zookeeper_path", std::make_shared<DataTypeString>() },
{ "replica_name", std::make_shared<DataTypeString>() },
{ "replica_path", std::make_shared<DataTypeString>() },
Expand Down Expand Up @@ -194,6 +195,7 @@ Pipe StorageSystemReplicas::read(
res_columns[col_num++]->insert(status.is_session_expired);
res_columns[col_num++]->insert(status.queue.future_parts);
res_columns[col_num++]->insert(status.parts_to_check);
res_columns[col_num++]->insert(status.zookeeper_name);
res_columns[col_num++]->insert(status.zookeeper_path);
res_columns[col_num++]->insert(status.replica_name);
res_columns[col_num++]->insert(status.replica_path);
Expand Down
Expand Up @@ -850,6 +850,7 @@ CREATE TABLE system.replicas
`is_session_expired` UInt8,
`future_parts` UInt32,
`parts_to_check` UInt32,
`zookeeper_name` String,
`zookeeper_path` String,
`replica_name` String,
`replica_path` String,
Expand Down
4 changes: 4 additions & 0 deletions tests/queries/0_stateless/02723_zookeeper_name.reference
@@ -0,0 +1,4 @@
Create Tables
Insert Data
"t1","default",1
"t2","default",1
23 changes: 23 additions & 0 deletions tests/queries/0_stateless/02723_zookeeper_name.sql
@@ -0,0 +1,23 @@
-- Tags: zookeeper, replica

SELECT 'Create Tables';
CREATE TABLE t1(k UInt32, v UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database}/test_02723/zookeeper_name/t1', '1') ORDER BY k;

CREATE TABLE t2(k UInt32, v UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database}/test_02723/zookeeper_name/t2', '1') ORDER BY k;

SELECT 'Insert Data';

INSERT INTO t1 SELECT * FROM generateRandom('k UInt32, v UInt32') LIMIT 1;
INSERT INTO t2 SELECT * FROM generateRandom('k UInt32, v UInt32') LIMIT 1;

SELECT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table,zookeeper_name,count()
FROM system.replicas
INNER JOIN system.parts USING (database, table)
WHERE database = currentDatabase()
GROUP BY
table,zookeeper_name
FORMAT CSV;

DROP TABLE t1;
DROP TABLE t2;