Skip to content

Commit

Permalink
Revert change of clickhouse client in replication-lag command
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Burmak committed Feb 4, 2024
1 parent f6c4f82 commit d9926e2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ch_tools/common/commands/replication_lag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from tabulate import tabulate

from ch_tools.common.clickhouse.client.clickhouse_client import clickhouse_client
from ch_tools.common.result import Result
from ch_tools.monrun_checks.clickhouse_client import ClickhouseClient

XCRIT = 3600
CRIT = 600
Expand All @@ -21,7 +21,7 @@ def estimate_replication_lag(
Should be: lag >= lag_with_errors, lag >= max_execution
"""
# pylint: disable=too-many-branches,too-many-locals
ch_client = clickhouse_client(ctx)
ch_client = ClickhouseClient(ctx)
lag, lag_with_errors, max_execution, max_merges, chart = get_replication_lag(
ch_client
)
Expand Down Expand Up @@ -188,7 +188,7 @@ def get_tables_with_replication_delay(ch_client):
Get tables with absolute_delay > 0.
"""
query = "SELECT database, table, zookeeper_path, absolute_delay FROM system.replicas WHERE absolute_delay > 0"
return ch_client.query(query=query, format_="JSON")["data"]
return ch_client.execute(query=query, compact=False)


def filter_out_single_replica_tables(ch_client, tables):
Expand All @@ -208,7 +208,7 @@ def filter_out_single_replica_tables(ch_client, tables):
"('{0}', '{1}')".format(t["database"], t["table"]) for t in tables
)
)
return ch_client.query(query=query, format_="JSON")["data"]
return ch_client.execute(query=query, compact=False)


def count_errors(ch_client, tables, exceptions_limit):
Expand Down Expand Up @@ -239,7 +239,7 @@ def count_errors(ch_client, tables, exceptions_limit):
),
limit=limit,
)
return ch_client.query(query=query, format_="JSON")["data"]
return ch_client.execute(query=query, compact=False)


def is_userfault_exception(exception):
Expand Down Expand Up @@ -268,7 +268,7 @@ def get_max_replicated_merges_in_queue(ch_client):
query = """
SELECT value FROM system.merge_tree_settings WHERE name='max_replicated_merges_in_queue'
"""
res = ch_client.query(query=query, format_="JSONCompact")["data"]
res = ch_client.execute(query=query, compact=True)
if not res:
return (
16 # 16 is default value for 'max_replicated_merges_in_queue' in ClickHouse
Expand Down

0 comments on commit d9926e2

Please sign in to comment.