From: lichaochao Date: Tue, 28 Mar 2023 03:17:26 +0000 (+0200) Subject: rgw: fix rgw cache invalidation after unregister_watch() error X-Git-Tag: v19.0.0~1423^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f9aae71af3ad8eee5996c31544d98041968dbbec;p=ceph-ci.git rgw: fix rgw cache invalidation after unregister_watch() error When a metadata osd fails, an unregister_watch() error may occur, resulting in an rgw cache invalidation. By adding an unregister_done flag and when a register_watch() error , performing a reinit() operation again, After the first reinit() failure, the register_watch() will be performed again Fixes: https://tracker.ceph.com/issues/59217 Signed-off-by: lichaochao --- diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index b0deefcfaf1..ff0080083f1 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -32,6 +32,7 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 { RGWSI_RADOS::Obj obj; uint64_t watch_handle; int register_ret{0}; + bool unregister_done{false}; librados::AioCompletion *register_completion{nullptr}; class C_ReinitWatch : public Context { @@ -85,20 +86,23 @@ public: } void reinit() { - int ret = unregister_watch(); - if (ret < 0) { - ldout(cct, 0) << "ERROR: unregister_watch() returned ret=" << ret << dendl; - return; + if(!unregister_done) { + int ret = unregister_watch(); + if (ret < 0) { + ldout(cct, 0) << "ERROR: unregister_watch() returned ret=" << ret << dendl; + } } - ret = register_watch(); + int ret = register_watch(); if (ret < 0) { ldout(cct, 0) << "ERROR: register_watch() returned ret=" << ret << dendl; + svc->schedule_context(new C_ReinitWatch(this)); return; } } int unregister_watch() { int r = svc->unwatch(obj, watch_handle); + unregister_done = true; if (r < 0) { return r; } @@ -135,6 +139,7 @@ public: return r; } svc->add_watcher(index); + unregister_done = false; return 0; } @@ -144,6 +149,7 @@ public: return r; } svc->add_watcher(index); + unregister_done = false; return 0; } };