]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/cloud-transition: fix the crash with accessing invalid attrs
authorSoumya Koduri <skoduri@redhat.com>
Thu, 9 May 2024 07:02:14 +0000 (12:32 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Thu, 9 May 2024 07:02:14 +0000 (12:32 +0530)
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 <skoduri@redhat.com>
src/rgw/rgw_lc.cc

index 799a74396cb05465fe1504209258fe040f5b69cc..a92272fdeec6cd34be82ab05abb89f848c8409e1 100644 (file)
@@ -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<rgw::sal::Object::DeleteOp> 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<rgw::sal::Notification> 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) <<