Skip to contentSkip to conversation

Distribute re-replicated objects evenly after OSD failure

RFC PATCH In review Jim Schutt 2 participants 5 messages May 10, 2012 – May 14, 2012

lore
Share & tools
lore

Jim Schutt

author
#0 lore raw

cover Distribute re-replicated objects evenly after OSD failure

Hi Sage,

I've been trying to solve the issue mentioned in tracker #2047, which I think is the same as I described in
http://www.spinics.net/lists/ceph-devel/msg05824.html

The attached patches seem to fix it for me. I also attempted to address the local search issue you mentioned in #2047.

I'm testing this using a cluster with 3 rows, 2 racks/row, 2 hosts/rack, 4 osds/host. I tested against a CRUSH map with the rules:
step take root
step chooseleaf firstn 0 type rack
step emit

I'm in the processes of testing this as follows:

I wrote some data to the cluster, then started shutting down OSDs using "init-ceph stop osd.n". For the first rack's worth, I shut OSDs down sequentially. I waited for recovery to complete each time before stopping the next OSD. For the next rack I shut down the first 3 OSDs on a host at the same time, waited for recovery to complete, then shut down the last OSD on that host. For the next racks, I shut down all the OSDs on the hosts in the rack at the same time.

Right now I'm waiting for recovery to complete after shutting down the third rack. Once recovery completed after each phase so far, there were no degraded objects.

So, this is looking fairly solid to me so far. What do you think?

Thanks -- Jim

Jim Schutt (2):
ceph: retry CRUSH map descent before retrying bucket
ceph: retry CRUSH map descent from root if leaf is failed

 src/crush/mapper.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.8.2
author
#1 lore raw

RFC PATCH 1/2 ceph: retry CRUSH map descent before retrying bucket

For the first few rejections or collisions, we'll retry the descent to keep objects spread across the cluster. After that, we'll fall back to exhaustive search of the bucket to avoid trying forever in the event a bucket has only a few in items and the hash doesn't do a good job of finding them.

---
 src/crush/mapper.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
src/crush/mapper.c +14 -6
index 8857577..e5dc950 100644
@@ -350,8 +350,7 @@ static int crush_choose(const struct crush_map *map,
 					reject = 1;
 					goto reject;
 				}
-				if (flocal >= (in->size>>1) &&
-				    flocal > orig_tries)
+				if (ftotal >= orig_tries)	 /* exhaustive bucket search */
 					item = bucket_perm_choose(in, x, r);
 				else
 					item = crush_bucket_choose(in, x, r);
@@ -420,10 +419,19 @@ reject:
 				if (reject || collide) {
 					ftotal++;
 					flocal++;
-
-					if (collide && flocal < 3)
-						/* retry locally a few times */
-						retry_bucket = 1;
+					/*
+					 * For the first couple rejections or collisions,
+					 * we'll retry the descent to keep objects spread
+					 * across the cluster.  After that, we'll fall back
+					 * to exhaustive search of buckets to avoid trying
+					 * forever in the event a bucket has only a few
+					 * "in" items and the hash doesn't do a good job
+					 * of finding them.  Note that we need to retry
+					 * descent during that phase so that multiple
+					 * buckets can be exhaustively searched.
+					 */
+					if (ftotal <= orig_tries)
+						retry_descent = 1;
 					else if (flocal <= in->size + orig_tries)
 						/* exhaustive bucket search */
 						retry_bucket = 1;
Signature · 1 line
1.7.8.2
author
#2 lore raw

RFC PATCH 2/2 ceph: retry CRUSH map descent from root if leaf is failed

In reply to Jim Schutt

When an object is re-replicated after a leaf failure, the remapped replica ends up under the bucket that held the failed leaf. This causes uneven data distribution across the storage cluster, to the point that when all the leaves of a bucket but one fail, that remaining leaf holds all the data from its failed peers.

For example, consider the crush rule
step chooseleaf firstn 0 type <node_type>

This rule means that <n> replicas will be chosen in such a manner that each chosen leaf's branch will contain a unique instance of <node_type>.

For such ops, the tree descent has two steps: call them the inner and outer descent.

If the tree descent down to <node_type> is the outer descent, and the descent from <node_type> down to a leaf is the inner descent, the issue is that a down leaf is detected on the inner descent, but we want to retry the outer descent. This ensures that re-replication after a leaf failure disperses the re-replicated objects as widely as possible across the storage cluster.

Fix this by causing the inner descent to return immediately on choosing a failed leaf, unless we've fallen back to exhaustive search.

Note that after this change, for a chooseleaf rule, if the primary OSD in a placement group has failed, choosing a replacement may result in one of the other OSDs in the PG colliding with the new primary. This requires that OSD's data for that PG to need moving as well. This seems unavoidable but should be relatively rare.

---
 src/crush/mapper.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
src/crush/mapper.c +9 -3
index e5dc950..698da55 100644
@@ -286,6 +286,7 @@ static int is_out(const struct crush_map *map, const __u32 *weight, int item, in
  * @param outpos our position in that vector
  * @param firstn true if choosing "first n" items, false if choosing "indep"
  * @param recurseto_leaf: true if we want one device under each item of given type
+ * @param descend_once true if we should only try one descent before giving up
  * @param out2 second output vector for leaf items (if @a recurse_to_leaf)
  */
 static int crush_choose(const struct crush_map *map,
@@ -293,7 +294,7 @@ static int crush_choose(const struct crush_map *map,
 			const __u32 *weight,
 			int x, int numrep, int type,
 			int *out, int outpos,
-			int firstn, int recurse_to_leaf,
+			int firstn, int recurse_to_leaf, int descend_once,
 			int *out2)
 {
 	int rep;
@@ -397,6 +398,7 @@ static int crush_choose(const struct crush_map *map,
 							 x, outpos+1, 0,
 							 out2, outpos,
 							 firstn, 0,
+							 ftotal < orig_tries,
 							 NULL) <= outpos)
 							/* didn't get leaf */
 							reject = 1;
@@ -430,7 +432,10 @@ reject:
 					 * descent during that phase so that multiple
 					 * buckets can be exhaustively searched.
 					 */
-					if (ftotal <= orig_tries)
+					if (reject && descend_once)
+						/* let outer call try again */
+						skip_rep = 1;
+					else if (ftotal <= orig_tries)
 						retry_descent = 1;
 					else if (flocal <= in->size + orig_tries)
 						/* exhaustive bucket search */
@@ -491,6 +496,7 @@ int crush_do_rule(const struct crush_map *map,
 	int i, j;
 	int numrep;
 	int firstn;
+	const int descend_once = 0;
 
 	if ((__u32)ruleno >= map->max_rules) {
 		dprintk(" bad ruleno %d\n", ruleno);
@@ -550,7 +556,7 @@ int crush_do_rule(const struct crush_map *map,
 						      curstep->arg2,
 						      o+osize, j,
 						      firstn,
-						      recurse_to_leaf, c+osize);
+						      recurse_to_leaf, descend_once, c+osize);
 			}
 
 			if (recurse_to_leaf)
Signature · 1 line
1.7.8.2
#3 lore raw
In reply to Jim Schutt

Hey Jim,

These both look like reasonable changes. And it's great to see they fix behavior for you.

I'm not going to merge them yet, though. We're just kicking off a CRUSH refresh project next week that will include some testing framework to more thoroughly validate the quality of the output, and also take a more holistic look at all what the algorithm is doing and see what we can improve. Most likely these changes will be included, but revving the mapping algorithm is going to be tricky for forward/backward compatibility, and we'd like to get it all in at once. (And/or come up with a better way to deal with mismatched versions...)

Thanks!
sage

Quoted 45 lines · Jim Schutt

Hi Sage,

I've been trying to solve the issue mentioned in tracker #2047, which I think is the same as I described in
http://www.spinics.net/lists/ceph-devel/msg05824.html

The attached patches seem to fix it for me. I also attempted to address the local search issue you mentioned in #2047.

I'm testing this using a cluster with 3 rows, 2 racks/row, 2 hosts/rack, 4 osds/host. I tested against a CRUSH map with the rules:
step take root
step chooseleaf firstn 0 type rack
step emit

I'm in the processes of testing this as follows:

I wrote some data to the cluster, then started shutting down OSDs using "init-ceph stop osd.n". For the first rack's worth, I shut OSDs down sequentially. I waited for recovery to complete each time before stopping the next OSD. For the next rack I shut down the first 3 OSDs on a host at the same time, waited for recovery to complete, then shut down the last OSD on that host. For the next racks, I shut down all the OSDs on the hosts in the rack at the same time.

Right now I'm waiting for recovery to complete after shutting down the third rack. Once recovery completed after each phase so far, there were no degraded objects.

So, this is looking fairly solid to me so far. What do you think?

Thanks -- Jim

Jim Schutt (2):
ceph: retry CRUSH map descent before retrying bucket
ceph: retry CRUSH map descent from root if leaf is failed

 src/crush/mapper.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.8.2
author
#4 lore raw
Quoted 10 lines · Sage Weil

Hey Jim,

These both look like reasonable changes. And it's great to see they fix behavior for you.

I'm not going to merge them yet, though. We're just kicking off a CRUSH refresh project next week that will include some testing framework to more thoroughly validate the quality of the output, and also take a more holistic look at all what the algorithm is doing and see what we can improve.

I really didn't expect you'd merge them right away -- I knew you had this CRUSH effort coming, so my goal was to get these to you so you could evaluate them as part of that push.

Quoted 4 lines

Most likely these changes will be included, but revving the mapping algorithm is going to be tricky for forward/backward compatibility, and we'd like to get it all in at once. (And/or come up with a better way to deal with mismatched versions...)

Yep, I completely ignored the version compatibility issue - I didn't have any clever ideas on how to handle it.

Also, FWIW I'm running with the patch below on top of the previous two - I think it helps avoid giving up too early in clusters where many OSDs have gone down/out, but I haven't done enough testing on it yet to quantify.

Quoted 2 lines

Thanks!

Hey, thanks for taking at look!

Quoted 1 line

sage

-- Jim

---
ceph: retry CRUSH map descents from root a little longer before falling back to exhaustive search

The exhaustive search isn't as exhaustive as we'd like if the CRUSH map is several levels deep, so try a few more times to find an "in" device during "spread re-replication around" mode. This makes it less likely we'll give up when the storage cluster has many failed devices.

---
 src/crush/mapper.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
src/crush/mapper.c +2 -2
index 698da55..39e9c5d 100644
@@ -306,7 +306,7 @@ static int crush_choose(const struct crush_map *map,
 	int item = 0;
 	int itemtype;
 	int collide, reject;
-	const unsigned int orig_tries = 5; /* attempts before we fall back to search */
+	const unsigned int orig_tries = 10; /* attempts before we fall back to search */
 
 	dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d\n", recurse_to_leaf ? "_LEAF" : "",
 		bucket->id, x, outpos, numrep);
@@ -440,7 +440,7 @@ reject:
 					else if (flocal <= in->size + orig_tries)
 						/* exhaustive bucket search */
 						retry_bucket = 1;
-					else if (ftotal < 20)
+					else if (ftotal <= orig_tries + 15)
 						/* then retry descent */
 						retry_descent = 1;
 					else
Signature · 1 line
1.7.8.2