From: kchheda3 Date: Thu, 4 Apr 2024 18:30:40 +0000 (-0400) Subject: rgw/notification: Load bucket attrs before calling publish_reserve. X-Git-Tag: testing/wip-batrick-testing-20240411.154038~29^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fa5d370663804db9752c99e79659aae031a7bf85;p=ceph-ci.git rgw/notification: Load bucket attrs before calling publish_reserve. As part of PR# 55657, publish_reserve would reload bucket to ensure bucket_attrs are loaded. However for lc events, where the bucket attrs were already loaded, the reloading was causing crash but there was no obvious root cause, so to avoid the crashes, remove reloading of bucket in publish_reserve and put the onus on callers to load the bucket before calling publish_reserve. Signed-off-by: kchheda3 --- diff --git a/src/rgw/driver/rados/rgw_cr_rados.cc b/src/rgw/driver/rados/rgw_cr_rados.cc index a717b971a89..51ebf95197e 100644 --- a/src/rgw/driver/rados/rgw_cr_rados.cc +++ b/src/rgw/driver/rados/rgw_cr_rados.cc @@ -741,6 +741,15 @@ int send_sync_notification(const DoutPrefixProvider* dpp, return -EIO; } } + // bucket attrs are required for notification and since its not loaded, + // reload the bucket + int r = bucket->load_bucket(dpp, null_yield); + if (r < 0) { + ldpp_dout(dpp, 1) << "ERROR: failed to load bucket attrs for bucket:" + << bucket->get_name() << " with error ret= " << r + << " . Not sending notification" << dendl; + return r; + } rgw::notify::reservation_t notify_res(dpp, store, obj, nullptr, bucket, user_id, bucket->get_tenant(), req_id, null_yield); diff --git a/src/rgw/driver/rados/rgw_notify.cc b/src/rgw/driver/rados/rgw_notify.cc index 3dc187367f0..179387f34ee 100644 --- a/src/rgw/driver/rados/rgw_notify.cc +++ b/src/rgw/driver/rados/rgw_notify.cc @@ -1,4 +1,4 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include "rgw_notify.h" @@ -1011,21 +1011,7 @@ int publish_reserve(const DoutPrefixProvider* dpp, rgw_pubsub_bucket_topics bucket_topics; if (all_zonegroups_support(site, zone_features::notification_v2) && res.store->stat_topics_v1(res.user_tenant, res.yield, res.dpp) == -ENOENT) { - auto ret = 0; - if (!res.s) { - // for non S3-request caller (e.g., lifecycle, ObjectSync), bucket attrs - // are not loaded, so force to reload the bucket, that reloads the attr. - // for non S3-request caller, res.s is nullptr - ret = res.bucket->load_bucket(dpp, res.yield); - if (ret < 0) { - ldpp_dout(dpp, 1) - << "ERROR: failed to reload bucket: '" << res.bucket->get_name() - << "' to get bucket notification attrs with error ret= " << ret - << dendl; - return ret; - } - } - ret = get_bucket_notifications(dpp, res.bucket, bucket_topics); + auto ret = get_bucket_notifications(dpp, res.bucket, bucket_topics); if (ret < 0) { return ret; }