From 6ceab5de1b04aab0b2f5f6a664181af5999e8c1e Mon Sep 17 00:00:00 2001 From: Pritha Srivastava Date: Wed, 14 Oct 2020 16:35:50 +0530 Subject: [PATCH] rgw/gc: fixing the condition when marker for a queue is always reset to empty which causes RGWGC::list to get stuck in a loop, which ultimately is broken out of when the queue's truncated flag is false. 1. Check for entries size also while evaluating whether objects cache for a gc object should be marked as 'transitioned' in case of cls_rgw_gc_list. When there are no entries, we get back a return value of 0, and the object cache is not marked as 'transitioned'. 2. Also for the last gc object, we need to check whether the queue is still under process and set the correct flag. Missing the two conditions above causes the GC::list to loop continously over the same gc object. Fixes: https://tracker.ceph.com/issues/47909 Signed-off-by: Pritha Srivastava (cherry picked from commit bf3f3ba675d092f48e403826fc0813e23c07045d) --- src/rgw/rgw_gc.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_gc.cc b/src/rgw/rgw_gc.cc index 98be34bf4c282..2a5a3a8bbb81f 100644 --- a/src/rgw/rgw_gc.cc +++ b/src/rgw/rgw_gc.cc @@ -208,7 +208,7 @@ int RGWGC::list(int *index, string& marker, uint32_t max, bool expired_only, std } obj_version objv; cls_version_read(store->gc_pool_ctx, obj_names[*index], &objv); - if (ret == -ENOENT) { + if (ret == -ENOENT || entries.size() == 0) { if (objv.ver == 0) { continue; } else { @@ -252,6 +252,11 @@ int RGWGC::list(int *index, string& marker, uint32_t max, bool expired_only, std marker = next_marker; if (*index == max_objs - 1) { + if (queue_entries.size() > 0 && *truncated) { + processing_queue = true; + } else { + processing_queue = false; + } /* we cut short here, truncated will hold the correct value */ return 0; } @@ -537,13 +542,13 @@ int RGWGC::process(int index, int max_secs, bool expired_only, if (non_expired_entries.size() == 0) { transitioned_objects_cache[index] = true; marker.clear(); - ldpp_dout(this, 20) << "RGWGC::process cls_rgw_gc_list returned ENOENT for non expired entries, so setting cache entry to TRUE" << dendl; + ldpp_dout(this, 20) << "RGWGC::process cls_rgw_gc_list returned NO non expired entries, so setting cache entry to TRUE" << dendl; } else { ret = 0; goto done; } } - if ((objv.ver == 0) && (ret == -ENOENT)) { + if ((objv.ver == 0) && (ret == -ENOENT || entries.size() == 0)) { ret = 0; goto done; } -- 2.39.5