From: Yehuda Sadeh Date: Fri, 13 Oct 2017 21:40:28 +0000 (-0700) Subject: rgw: recover from empty meta.history object X-Git-Tag: v13.1.0~270^2~80 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fe0807fc371ab9a75e1bf53817d1e7685d669f62;p=ceph.git rgw: recover from empty meta.history object 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 --- diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index 8baa3dd30874..0c6ac0a92241 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -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);