From 99cbdf522a8d13e2bbe37ee72d1c576833e2cd0b Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 13 Nov 2018 16:50:34 -0500 Subject: [PATCH] rgw: pool_iterate[_begin] catches NObjectIterator exceptions Fixes: http://tracker.ceph.com/issues/37091 Signed-off-by: Casey Bodley --- src/rgw/rgw_rados.cc | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 9c3aeb6f4693b..4b6ac668678ec 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -8416,9 +8416,19 @@ int RGWRados::pool_iterate_begin(const rgw_pool& pool, const string& cursor, RGW return -EINVAL; } - iter = io_ctx.nobjects_begin(oc); - - return 0; + try { + iter = io_ctx.nobjects_begin(oc); + return 0; + } catch (const std::system_error& e) { + r = -e.code().value(); + ldout(cct, 10) << "nobjects_begin threw " << e.what() + << ", returning " << r << dendl; + return r; + } catch (const std::exception& e) { + ldout(cct, 10) << "nobjects_begin threw " << e.what() + << ", returning -5" << dendl; + return -EIO; + } } string RGWRados::pool_iterate_get_cursor(RGWPoolIterCtx& ctx) @@ -8426,7 +8436,8 @@ string RGWRados::pool_iterate_get_cursor(RGWPoolIterCtx& ctx) return ctx.iter.get_cursor().to_str(); } -int RGWRados::pool_iterate(RGWPoolIterCtx& ctx, uint32_t num, vector& objs, +static int do_pool_iterate(CephContext* cct, RGWPoolIterCtx& ctx, uint32_t num, + vector& objs, bool *is_truncated, RGWAccessListFilter *filter) { librados::IoCtx& io_ctx = ctx.io_ctx; @@ -8457,6 +8468,24 @@ int RGWRados::pool_iterate(RGWPoolIterCtx& ctx, uint32_t num, vector& objs, + bool *is_truncated, RGWAccessListFilter *filter) +{ + // catch exceptions from NObjectIterator::operator++() + try { + return do_pool_iterate(cct, ctx, num, objs, is_truncated, filter); + } catch (const std::system_error& e) { + int r = -e.code().value(); + ldout(cct, 10) << "NObjectIterator threw exception " << e.what() + << ", returning " << r << dendl; + return r; + } catch (const std::exception& e) { + ldout(cct, 10) << "NObjectIterator threw exception " << e.what() + << ", returning -5" << dendl; + return -EIO; + } +} + int RGWRados::list_raw_objects_init(const rgw_pool& pool, const string& marker, RGWListRawObjsCtx *ctx) { if (!ctx->initialized) { -- 2.39.5