]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: recover from empty meta.history object
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 13 Oct 2017 21:40:28 +0000 (14:40 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:05:38 +0000 (08:05 -0700)
Fixes: http://tracker.ceph.com/issues/21802
Empty meta.history object is problematic, as when reading it when doing
meta log trimming, we'd just initialize it to an empty structure, and
end up asserting because cursor is empty. Cannot just return -ENOENT
here, because it wouldn't solve the issue.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_metadata.cc

index 8baa3dd30874dd8ebddb3391b19f96a46db05a03..0c6ac0a92241b42ae237eca24e40aeb8a2885dd7 100644 (file)
@@ -364,6 +364,16 @@ int read_history(RGWRados *store, RGWMetadataLogHistory *state,
   if (ret < 0) {
     return ret;
   }
+  if (bl.length() == 0) {
+    /* bad history object, remove it */
+    rgw_raw_obj obj(pool, oid);
+    ret = store->delete_system_obj(obj);
+    if (ret < 0) {
+      ldout(store->ctx(), 0) << "ERROR: meta history is empty, but cannot remove it (" << cpp_strerror(-ret) << ")" << dendl;
+      return ret;
+    }
+    return -ENOENT;
+  }
   try {
     auto p = bl.begin();
     state->decode(p);