From 2b2c01240c3e11a1caa7596eb17710dd8f8090bd Mon Sep 17 00:00:00 2001 From: James Greenhill Date: Sat, 8 Jun 2024 09:41:41 -0700 Subject: [PATCH] chore: randomize more and name non-sharded backups noshard (#69) --- housewatch/clickhouse/backups.py | 2 +- housewatch/clickhouse/clusters.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/housewatch/clickhouse/backups.py b/housewatch/clickhouse/backups.py index 3c0a181..1674fa8 100644 --- a/housewatch/clickhouse/backups.py +++ b/housewatch/clickhouse/backups.py @@ -36,7 +36,7 @@ def execute_backup( nodes = get_node_per_shard(cluster) responses = [] for shard, node in nodes: - params["shard"] = shard + params["shard"] = shard if is_sharded else "noshard" if base_backup: query_settings["base_backup"] = f"S3('{base_backup}/{shard}', '{aws_key}', '{aws_secret}')" final_query = query % (params or {}) if substitute_params else query diff --git a/housewatch/clickhouse/clusters.py b/housewatch/clickhouse/clusters.py index 7ea8065..03d5b4d 100644 --- a/housewatch/clickhouse/clusters.py +++ b/housewatch/clickhouse/clusters.py @@ -48,4 +48,5 @@ def get_node_per_shard(cluster): break if not preferred_replica_found: nodes.append((shard, random.choice(n))) + random.shuffle(nodes) return nodes