Skip to content

Commit fa5d370

Browse files
committed
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 <[email protected]>
1 parent 9d29fa7 commit fa5d370

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/rgw/driver/rados/rgw_cr_rados.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,15 @@ int send_sync_notification(const DoutPrefixProvider* dpp,
741741
return -EIO;
742742
}
743743
}
744+
// bucket attrs are required for notification and since its not loaded,
745+
// reload the bucket
746+
int r = bucket->load_bucket(dpp, null_yield);
747+
if (r < 0) {
748+
ldpp_dout(dpp, 1) << "ERROR: failed to load bucket attrs for bucket:"
749+
<< bucket->get_name() << " with error ret= " << r
750+
<< " . Not sending notification" << dendl;
751+
return r;
752+
}
744753
rgw::notify::reservation_t notify_res(dpp, store, obj, nullptr, bucket,
745754
user_id, bucket->get_tenant(), req_id,
746755
null_yield);

src/rgw/driver/rados/rgw_notify.cc

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
22
// vim: ts=8 sw=2 smarttab
33

44
#include "rgw_notify.h"
@@ -1011,21 +1011,7 @@ int publish_reserve(const DoutPrefixProvider* dpp,
10111011
rgw_pubsub_bucket_topics bucket_topics;
10121012
if (all_zonegroups_support(site, zone_features::notification_v2) &&
10131013
res.store->stat_topics_v1(res.user_tenant, res.yield, res.dpp) == -ENOENT) {
1014-
auto ret = 0;
1015-
if (!res.s) {
1016-
// for non S3-request caller (e.g., lifecycle, ObjectSync), bucket attrs
1017-
// are not loaded, so force to reload the bucket, that reloads the attr.
1018-
// for non S3-request caller, res.s is nullptr
1019-
ret = res.bucket->load_bucket(dpp, res.yield);
1020-
if (ret < 0) {
1021-
ldpp_dout(dpp, 1)
1022-
<< "ERROR: failed to reload bucket: '" << res.bucket->get_name()
1023-
<< "' to get bucket notification attrs with error ret= " << ret
1024-
<< dendl;
1025-
return ret;
1026-
}
1027-
}
1028-
ret = get_bucket_notifications(dpp, res.bucket, bucket_topics);
1014+
auto ret = get_bucket_notifications(dpp, res.bucket, bucket_topics);
10291015
if (ret < 0) {
10301016
return ret;
10311017
}

0 commit comments

Comments
 (0)