From fe0807fc371ab9a75e1bf53817d1e7685d669f62 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 13 Oct 2017 14:40:28 -0700 Subject: 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 --- src/rgw/rgw_metadata.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/rgw/rgw_metadata.cc') diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index 8baa3dd3087..0c6ac0a9224 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); -- cgit v1.2.3