summaryrefslogtreecommitdiff
path: root/swift/common/db_replicator.py
diff options
context:
space:
mode:
authorMatthew Oliver <matt@oliver.net.au>2022-07-21 12:32:27 +1000
committerAlistair Coles <alistairncoles@gmail.com>2022-07-29 15:02:26 +0100
commitc4e00eb89f34de79d5fb123dd044621ef4df679c (patch)
tree6c9cb018bc19c4b4592b376087d09928cb59084d /swift/common/db_replicator.py
parentd7a931191b805f9f14f57d91532d88bba88cf362 (diff)
downloadswift-c4e00eb89f34de79d5fb123dd044621ef4df679c.tar.gz
Sharder: Fall back to local device in get_shard_broker
If the sharder is processing a node that has 0 weight, especially for all the devices on the node, the `find_local_handoff_for_part` can fail because there will be no local hand off devices available as it uses the replica2part2dev_id to find a device. However, a 0 weighted device won't appear in the replica2part2dev table. This patch extends `find_local_handoff_for_part`, if it fails to find a node from the ring it'll fall back to a local device identified by the `_local_device_ids` that is built up when the replicator or sharder was identifing local devices. This uses the ring.devs, so does include 0 weighted devices. This allows the sharder to find a location to write the shard_broker in a handoff location while sharding. Co-Authored-By: Tim Burke <tim.burke@gmail.com> Change-Id: Ic38698e9ca0397770c7362229baef1101a72788f
Diffstat (limited to 'swift/common/db_replicator.py')
-rw-r--r--swift/common/db_replicator.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py
index 0db65b2a3..3e82e2dd8 100644
--- a/swift/common/db_replicator.py
+++ b/swift/common/db_replicator.py
@@ -196,7 +196,7 @@ class Replicator(Daemon):
self.cpool = GreenPool(size=concurrency)
swift_dir = conf.get('swift_dir', '/etc/swift')
self.ring = ring.Ring(swift_dir, ring_name=self.server_type)
- self._local_device_ids = set()
+ self._local_device_ids = {}
self.per_diff = int(conf.get('per_diff', 1000))
self.max_diffs = int(conf.get('max_diffs') or 100)
self.interval = float(conf.get('interval') or
@@ -795,7 +795,7 @@ class Replicator(Daemon):
'These modes are not intended for normal '
'operation; use these options with care.')
- self._local_device_ids = set()
+ self._local_device_ids = {}
found_local = False
for node in self.ring.devs:
if node and is_local_device(ips, self.port,
@@ -822,7 +822,7 @@ class Replicator(Daemon):
time.time() - self.reclaim_age)
datadir = os.path.join(self.root, node['device'], self.datadir)
if os.path.isdir(datadir):
- self._local_device_ids.add(node['id'])
+ self._local_device_ids[node['id']] = node
part_filt = self._partition_dir_filter(
node['id'], partitions_to_replicate)
dirs.append((datadir, node['id'], part_filt))