]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/notification: Load bucket attrs before calling publish_reserve.
authorkchheda3 <kchheda3@bloomberg.net>
Thu, 4 Apr 2024 18:30:40 +0000 (14:30 -0400)
committerkchheda3 <kchheda3@bloomberg.net>
Thu, 4 Apr 2024 19:15:38 +0000 (15:15 -0400)
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 <kchheda3@bloomberg.net>
src/rgw/driver/rados/rgw_cr_rados.cc
src/rgw/driver/rados/rgw_notify.cc

index a717b971a89609307f50486c26465b10b9321d3a..51ebf95197eb20072d15cb079e12c6921a08414a 100644 (file)
@@ -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);
index 3dc187367f0b8fdfe06eb27424c6d49e67b0ec52..179387f34ee161e2b2a045d2500a8a4826e63cfa 100644 (file)
@@ -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;
     }