From e3207e3c12126ddcd5c123d19f85bd113a11283f Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Thu, 9 May 2024 12:32:14 +0530 Subject: [PATCH] rgw/cloud-transition: fix the crash with accessing invalid attrs The obj_state may not be valid anymore post LC operations (esp., cloud-transition). Hence read and store etag prior to them to be used later by notification (publish_commit). Fixes: https://tracker.ceph.com/issues/65862 Signed-off-by: Soumya Koduri --- src/rgw/rgw_lc.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 799a74396cb05..a92272fdeec6c 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -586,10 +586,15 @@ static int remove_expired_obj(const DoutPrefixProvider* dpp, auto obj = oc.bucket->get_object(obj_key); RGWObjState* obj_state{nullptr}; + string etag; ret = obj->get_obj_state(dpp, &obj_state, null_yield, true); if (ret < 0) { return ret; } + auto iter = obj_state->attrset.find(RGW_ATTR_ETAG); + if (iter != obj_state->attrset.end()) { + etag = rgw_bl_str(iter->second); + } std::unique_ptr del_op = obj->get_delete_op(); @@ -624,7 +629,7 @@ static int remove_expired_obj(const DoutPrefixProvider* dpp, // send request to notification manager int publish_ret = notify->publish_commit(dpp, obj_state->size, ceph::real_clock::now(), - obj_state->attrset[RGW_ATTR_ETAG].to_str(), + etag, version_id); if (publish_ret < 0) { ldpp_dout(dpp, 5) << "WARNING: notify publish_commit failed, with error: " << publish_ret << dendl; @@ -890,10 +895,15 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, auto sal_obj = target->get_object(key); RGWObjState* obj_state{nullptr}; + string etag; ret = sal_obj->get_obj_state(this, &obj_state, null_yield, true); if (ret < 0) { return ret; } + auto iter = obj_state->attrset.find(RGW_ATTR_ETAG); + if (iter != obj_state->attrset.end()) { + etag = rgw_bl_str(iter->second); + } std::unique_ptr notify = driver->get_notification( @@ -917,7 +927,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, int publish_ret = notify->publish_commit( this, obj_state->size, ceph::real_clock::now(), - obj_state->attrset[RGW_ATTR_ETAG].to_str(), + etag, version_id); if (publish_ret < 0) { ldpp_dout(wk->get_lc(), 5) @@ -1405,10 +1415,15 @@ public: auto& obj = oc.obj; RGWObjState* obj_state{nullptr}; + string etag; ret = obj->get_obj_state(oc.dpp, &obj_state, null_yield, true); if (ret < 0) { return ret; } + auto iter = obj_state->attrset.find(RGW_ATTR_ETAG); + if (iter != obj_state->attrset.end()) { + etag = rgw_bl_str(iter->second); + } rgw::notify::EventTypeList event_types; if (bucket->versioned() && oc.o.is_current() && !oc.o.is_delete_marker()) { @@ -1445,7 +1460,7 @@ public: // send request to notification manager int publish_ret = notify->publish_commit(oc.dpp, obj_state->size, ceph::real_clock::now(), - obj_state->attrset[RGW_ATTR_ETAG].to_str(), + etag, version_id); if (publish_ret < 0) { ldpp_dout(oc.dpp, 5) << -- 2.39.5