From ebb37c7bb3aee4663220054c6516164bf046fa8c Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 3 May 2024 15:43:39 -0400 Subject: [PATCH] rgw: move publish_complete() back to RGWCompleteMultipart::execute() move publish_complete() and meta_obj->delete_object() back to execute() so they only run on success. this allows several member variables to move back to execute()'s stack as well Fixes: https://tracker.ceph.com/issues/65746 Signed-off-by: Casey Bodley --- src/rgw/rgw_op.cc | 59 ++++++++++++++++++----------------------------- src/rgw/rgw_op.h | 2 -- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index c08697786a90f..61191b14e4990 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -6293,6 +6293,7 @@ void RGWCompleteMultipart::execute(optional_yield y) RGWMultiCompleteUpload *parts; RGWMultiXMLParser parser; std::unique_ptr upload; + off_t ofs = 0; uint64_t olh_epoch = 0; op_ret = get_params(y); @@ -6344,7 +6345,7 @@ void RGWCompleteMultipart::execute(optional_yield y) list remove_objs; /* objects to be removed from index listing */ - meta_obj = upload->get_meta_obj(); + std::unique_ptr meta_obj = upload->get_meta_obj(); meta_obj->set_in_extra_data(true); meta_obj->set_hash_source(s->object->get_name()); @@ -6390,6 +6391,7 @@ void RGWCompleteMultipart::execute(optional_yield y) s->object->set_attrs(meta_obj->get_attrs()); // make reservation for notification if needed + std::unique_ptr res; res = driver->get_notification(s->object.get(), nullptr, s, rgw::notify::ObjectCreatedCompleteMultipartUpload, y); op_ret = res->publish_reserve(this); if (op_ret < 0) { @@ -6402,11 +6404,26 @@ void RGWCompleteMultipart::execute(optional_yield y) return; } - upload_time = upload->get_mtime(); - int r = serializer->unlock(); - if (r < 0) { - ldpp_dout(this, 0) << "WARNING: failed to unlock " << *serializer.get() << dendl; + const ceph::real_time upload_time = upload->get_mtime(); + etag = s->object->get_attrs()[RGW_ATTR_ETAG].to_str(); + + // send request to notification manager + int ret = res->publish_commit(this, ofs, upload_time, etag, s->object->get_instance()); + if (ret < 0) { + ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl; + // too late to rollback operation, hence op_ret is not set here } + + // remove the upload meta object ; the meta object is not versioned + // when the bucket is, as that would add an unneeded delete marker + ret = meta_obj->delete_object(this, y, rgw::sal::FLAG_PREVENT_VERSIONING); + if (ret >= 0) { + /* serializer's exclusive lock is released */ + serializer->clear_locked(); + } else { + ldpp_dout(this, 4) << "WARNING: failed to remove object " << meta_obj << ", ret: " << ret << dendl; + } + } // RGWCompleteMultipart::execute bool RGWCompleteMultipart::check_previously_completed(const RGWMultiCompleteUpload* parts) @@ -6458,38 +6475,6 @@ void RGWCompleteMultipart::complete() } } - if (op_ret >= 0) { - etag = s->object->get_attrs()[RGW_ATTR_ETAG].to_str(); - // send request to notification manager - if (res.get() != nullptr) { - int ret = res->publish_commit(this, ofs, upload_time, etag, s->object->get_instance()); - if (ret < 0) { - ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl; - // too late to rollback operation, hence op_ret is not set here - } - } else { - ldpp_dout(this, 1) << "ERROR: reservation is null" << dendl; - } - } - - // remove the upload meta object ; the meta object is not versioned - // when the bucket is, as that would add an unneeded delete marker - // moved to complete to prevent segmentation fault in publish commit - if (meta_obj.get() != nullptr) { - int ret = meta_obj->delete_object(this, null_yield, rgw::sal::FLAG_PREVENT_VERSIONING); - if (ret >= 0) { - /* serializer's exclusive lock is released */ - serializer->clear_locked(); - } else { - ldpp_dout(this, 0) << "WARNING: failed to remove object " << meta_obj << ", ret: " << ret << dendl; - } - } else { - ldpp_dout(this, 0) << "WARNING: meta_obj is null" << dendl; - } - - res.reset(); - meta_obj.reset(); - send_response(); } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index f826d3d139d62..8fe5540e96d94 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -1872,8 +1872,6 @@ protected: jspan_ptr multipart_trace; ceph::real_time upload_time; std::unique_ptr res; - std::unique_ptr meta_obj; - off_t ofs = 0; public: RGWCompleteMultipart() {} -- 2.39.5