]> 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, 34597/head
authorShilpa Jagannath <smanjara@redhat.com>
Tue, 26 Nov 2019 08:03:52 +0000 (13:33 +0530)
committerNathan Cutler <ncutler@suse.com>
Thu, 16 Apr 2020 20:32:02 +0000 (22:32 +0200)
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 nautilus; made the changes manually to
  src/rgw/rgw_metadata.cc

src/rgw/rgw_metadata.cc

index b894bb99aeab2b9eeafe24e3649672fd8d543c34..9741cba9dcbd6fe86d8a5371c245ab20c922951c 100644 (file)
@@ -541,7 +541,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) {
@@ -596,7 +596,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);