From 87bbd654b9497606796b95a6e59f74be26fc0509 Mon Sep 17 00:00:00 2001 From: kchheda3 Date: Thu, 4 Apr 2024 14:30:40 -0400 Subject: [PATCH] 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 (cherry picked from commit fa5d370663804db9752c99e79659aae031a7bf85) --- src/rgw/driver/rados/rgw_cr_rados.cc | 9 +++++++++ src/rgw/driver/rados/rgw_notify.cc | 18 ++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/rgw/driver/rados/rgw_cr_rados.cc b/src/rgw/driver/rados/rgw_cr_rados.cc index a717b971a8960..51ebf95197eb2 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 31cae8daa31c8..542be2ce5551a 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" @@ -989,21 +989,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; } -- 2.39.5