]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: when a period lookup for oldest_realm_epoch returns an ENOENT, 33309/head
authorShilpa Jagannath <smanjara@redhat.com>
Tue, 26 Nov 2019 08:03:52 +0000 (13:33 +0530)
committerNathan Cutler <ncutler@suse.com>
Fri, 14 Feb 2020 11:52:27 +0000 (12:52 +0100)
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>
(cherry picked from commit 0ea65d81d4d5431ca22340149dbd714e395ecdc3)

Conflicts:
src/rgw/services/svc_mdlog.cc
- file does not exist in mimic; made the changes manually to
  src/rgw/rgw_metadata.cc
- in mimic, find_oldest_period takes an argument: store
- in mimic, write_history takes an additional argument: store

src/rgw/rgw_metadata.cc

index ed237b9e45d16bab3f7de578a35125c82e7935b2..4d2c5a2c61da6106b45ff31761819292ffc3ac2b 100644 (file)
@@ -536,7 +536,7 @@ Cursor find_oldest_period(RGWRados *store)
       RGWPeriod period;
       int r = store->period_puller->pull(predecessor, period);
       if (r < 0) {
-        return Cursor{r};
+        return cursor;
       }
       auto prev = store->period_history->insert(std::move(period));
       if (!prev) {
@@ -568,7 +568,6 @@ Cursor RGWMetadataManager::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();
@@ -591,7 +590,20 @@ Cursor RGWMetadataManager::init_oldest_log_period()
   auto cursor = store->period_history->lookup(state.oldest_realm_epoch);
   if (cursor) {
     return cursor;
+  } else {
+    cursor = find_oldest_period(store);
+    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(store, 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 = store->period_puller->pull(state.oldest_period_id, period);