From: Casey Bodley Date: Tue, 13 Nov 2018 21:50:34 +0000 (-0500) Subject: rgw: pool_iterate[_begin] catches NObjectIterator exceptions X-Git-Tag: v14.1.0~761^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=99cbdf522a8d13e2bbe37ee72d1c576833e2cd0b;p=ceph.git rgw: pool_iterate[_begin] catches NObjectIterator exceptions Fixes: http://tracker.ceph.com/issues/37091 Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 9c3aeb6f4693..4b6ac668678e 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) {