]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: when a period lookup for oldest_realm_epoch returns an ENOENT, 31873/head
authorShilpa Jagannath <smanjara@redhat.com>
Tue, 26 Nov 2019 08:03:52 +0000 (13:33 +0530)
committerShilpa Jagannath <smanjara@redhat.com>
Fri, 6 Dec 2019 13:05:30 +0000 (18:35 +0530)
find the oldest one and update RGWMetadataLogHistory. This is to avoid an
empty cursor being passed in to ceph_assert() in PurgePeriodLogsCR::operate()
in case of incomplete period history.

Fixes: https://tracker.ceph.com/issues/40341
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
src/rgw/services/svc_mdlog.cc

index 78a026040bbecc36903043ce136d754aeaae5bb5..e98d1f566c5c50f1c9758604ac73dda643a1f094 100644 (file)
@@ -260,7 +260,7 @@ Cursor RGWSI_MDLog::find_oldest_period()
       RGWPeriod period;
       int r = period_puller->pull(predecessor, period);
       if (r < 0) {
-        return Cursor{r};
+        return cursor;
       }
       auto prev = period_history->insert(std::move(period));
       if (!prev) {
@@ -290,7 +290,6 @@ Cursor RGWSI_MDLog::init_oldest_log_period()
     if (!cursor) {
       return cursor;
     }
-
     // write the initial history
     state.oldest_realm_epoch = cursor.get_epoch();
     state.oldest_period_id = cursor.get_period().get_id();
@@ -313,7 +312,20 @@ Cursor RGWSI_MDLog::init_oldest_log_period()
   auto cursor = period_history->lookup(state.oldest_realm_epoch);
   if (cursor) {
     return cursor;
+  } else {
+    cursor = find_oldest_period();
+    state.oldest_realm_epoch = cursor.get_epoch();
+    state.oldest_period_id = cursor.get_period().get_id();
+    ldout(cct, 10) << "rewriting mdlog history" << dendl;
+    ret = write_history(state, &objv);
+    if (ret < 0 && ret != -ECANCELED) {
+    ldout(cct, 1) << "failed to write mdlog history: "
+          << cpp_strerror(ret) << dendl;
+    return Cursor{ret};
+    }
+    return cursor;
   }
+
   // pull the oldest period by id
   RGWPeriod period;
   ret = period_puller->pull(state.oldest_period_id, period);