File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ def execute_backup(
30
30
):
31
31
"""
32
32
This function will execute a backup on each shard in a cluster
33
- This is very similar to run_query_on_shards but it has very specific things for backups
34
- specifically around base_backup settings
33
+ This is very similar to run_query_on_shards but it has very specific params
34
+ for backups - specifically around base_backup settings
35
35
"""
36
36
nodes = get_node_per_shard (cluster )
37
37
responses = []
Original file line number Diff line number Diff line change
1
+ import random
1
2
from collections import defaultdict
2
3
from housewatch .clickhouse .client import run_query
3
4
@@ -38,11 +39,13 @@ def get_node_per_shard(cluster):
38
39
preferred = PreferredReplica .objects .filter (cluster = cluster ).values_list ("replica" , flat = True )
39
40
for shard , n in shards .items ():
40
41
preferred_replica_found = False
42
+ # shuffle the nodes so we don't always pick the first preferred one
43
+ random .shuffle (n )
41
44
for node in n :
42
45
if node ["host_name" ] in preferred :
43
46
nodes .append ((shard , node ))
44
47
preferred_replica_found = True
45
48
break
46
49
if not preferred_replica_found :
47
- nodes .append ((shard , n [ 0 ] ))
50
+ nodes .append ((shard , random . choice ( n ) ))
48
51
return nodes
Original file line number Diff line number Diff line change 26
26
27
27
28
28
sentry_sdk .init (
29
- dsn = "https://6a05afd8bf4e2d54c81833ca1ff98cca@o607503 .ingest.sentry.io/4505874503237633 " ,
29
+ dsn = "https://8874d21e05d62df688505df70c9f053d@o1015702 .ingest.us. sentry.io/4507393944846336 " ,
30
30
integrations = [DjangoIntegration ()],
31
31
# If you wish to associate users to errors (assuming you are using
32
32
# django.contrib.auth) you may enable sending PII data.
You can’t perform that action at this time.
0 commit comments