Skip to content

Commit

Permalink
Metatdata cleaner with system drop replica
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailBurdukov committed Oct 4, 2024
1 parent 8e11eb0 commit de6a77d
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 142 deletions.
10 changes: 10 additions & 0 deletions ch_tools/chadmin/internal/database_replica.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from ch_tools.chadmin.internal.utils import execute_query


def system_database_drop_replica(ctx, database_zk_path, replica, dry_run=False):
"""
Perform "SYSTEM DROP DATABASE REPLICA" query.
"""
timeout = ctx.obj["config"]["clickhouse"]["drop_replica_timeout"]
query = f"SYSTEM DROP DATABASE REPLICA '{replica}' FROM ZKPATH '{database_zk_path}'"
execute_query(ctx, query, timeout=timeout, echo=True, dry_run=dry_run, format_=None)
9 changes: 9 additions & 0 deletions ch_tools/chadmin/internal/table_replica.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,12 @@ def restore_table_replica(
if cluster:
query += f" ON CLUSTER '{cluster}'"
execute_query(ctx, query, timeout=timeout, echo=True, dry_run=dry_run, format_=None)


def system_table_drop_replica(ctx, table_zk_path, replica, dry_run=False):
"""
Perform "SYSTEM DROP REPLICA" query.
"""
timeout = ctx.obj["config"]["clickhouse"]["drop_replica_timeout"]
query = f"SYSTEM DROP REPLICA '{replica}' FROM ZKPATH '{table_zk_path}'"
execute_query(ctx, query, timeout=timeout, echo=True, dry_run=dry_run, format_=None)
Loading

0 comments on commit de6a77d

Please sign in to comment.