Skip to content

Commit 00829d8

Browse files
authored
Merge pull request #57257 from cbodley/wip-65746
rgw: fix CompleteMultipart error handling regression Reviewed-by: Ali Masarwa <amasarwa@redhat.com> Reviewed-by: Matt Benjamin <mbenjamin@redhat.com>
2 parents 4a84231 + ebb37c7 commit 00829d8

File tree

2 files changed

+34
-60
lines changed

2 files changed

+34
-60
lines changed

src/rgw/rgw_op.cc

Lines changed: 34 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6293,6 +6293,7 @@ void RGWCompleteMultipart::execute(optional_yield y)
62936293
RGWMultiCompleteUpload *parts;
62946294
RGWMultiXMLParser parser;
62956295
std::unique_ptr<rgw::sal::MultipartUpload> upload;
6296+
off_t ofs = 0;
62966297
uint64_t olh_epoch = 0;
62976298

62986299
op_ret = get_params(y);
@@ -6344,7 +6345,7 @@ void RGWCompleteMultipart::execute(optional_yield y)
63446345

63456346
list<rgw_obj_index_key> remove_objs; /* objects to be removed from index listing */
63466347

6347-
meta_obj = upload->get_meta_obj();
6348+
std::unique_ptr<rgw::sal::Object> meta_obj = upload->get_meta_obj();
63486349
meta_obj->set_in_extra_data(true);
63496350
meta_obj->set_hash_source(s->object->get_name());
63506351

@@ -6378,38 +6379,51 @@ void RGWCompleteMultipart::execute(optional_yield y)
63786379
jspan_context trace_ctx(false, false);
63796380
extract_span_context(meta_obj->get_attrs(), trace_ctx);
63806381
multipart_trace = tracing::rgw::tracer.add_span(name(), trace_ctx);
6381-
63826382

6383-
// make reservation for notification if needed
6384-
res = driver->get_notification(meta_obj.get(), nullptr, s, rgw::notify::ObjectCreatedCompleteMultipartUpload, y,
6385-
&s->object->get_name());
6386-
op_ret = res->publish_reserve(this);
6387-
if (op_ret < 0) {
6388-
return;
6389-
}
6390-
6391-
target_obj = s->bucket->get_object(rgw_obj_key(s->object->get_name()));
63926383
if (s->bucket->versioning_enabled()) {
63936384
if (!version_id.empty()) {
6394-
target_obj->set_instance(version_id);
6385+
s->object->set_instance(version_id);
63956386
} else {
6396-
target_obj->gen_rand_obj_instance_name();
6397-
version_id = target_obj->get_instance();
6387+
s->object->gen_rand_obj_instance_name();
6388+
version_id = s->object->get_instance();
63986389
}
63996390
}
6400-
target_obj->set_attrs(meta_obj->get_attrs());
6391+
s->object->set_attrs(meta_obj->get_attrs());
64016392

6402-
op_ret = upload->complete(this, y, s->cct, parts->parts, remove_objs, accounted_size, compressed, cs_info, ofs, s->req_id, s->owner, olh_epoch, target_obj.get());
6393+
// make reservation for notification if needed
6394+
std::unique_ptr<rgw::sal::Notification> res;
6395+
res = driver->get_notification(s->object.get(), nullptr, s, rgw::notify::ObjectCreatedCompleteMultipartUpload, y);
6396+
op_ret = res->publish_reserve(this);
6397+
if (op_ret < 0) {
6398+
return;
6399+
}
6400+
6401+
op_ret = upload->complete(this, y, s->cct, parts->parts, remove_objs, accounted_size, compressed, cs_info, ofs, s->req_id, s->owner, olh_epoch, s->object.get());
64036402
if (op_ret < 0) {
64046403
ldpp_dout(this, 0) << "ERROR: upload complete failed ret=" << op_ret << dendl;
64056404
return;
64066405
}
64076406

6408-
upload_time = upload->get_mtime();
6409-
int r = serializer->unlock();
6410-
if (r < 0) {
6411-
ldpp_dout(this, 0) << "WARNING: failed to unlock " << *serializer.get() << dendl;
6407+
const ceph::real_time upload_time = upload->get_mtime();
6408+
etag = s->object->get_attrs()[RGW_ATTR_ETAG].to_str();
6409+
6410+
// send request to notification manager
6411+
int ret = res->publish_commit(this, ofs, upload_time, etag, s->object->get_instance());
6412+
if (ret < 0) {
6413+
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
6414+
// too late to rollback operation, hence op_ret is not set here
6415+
}
6416+
6417+
// remove the upload meta object ; the meta object is not versioned
6418+
// when the bucket is, as that would add an unneeded delete marker
6419+
ret = meta_obj->delete_object(this, y, rgw::sal::FLAG_PREVENT_VERSIONING);
6420+
if (ret >= 0) {
6421+
/* serializer's exclusive lock is released */
6422+
serializer->clear_locked();
6423+
} else {
6424+
ldpp_dout(this, 4) << "WARNING: failed to remove object " << meta_obj << ", ret: " << ret << dendl;
64126425
}
6426+
64136427
} // RGWCompleteMultipart::execute
64146428

64156429
bool RGWCompleteMultipart::check_previously_completed(const RGWMultiCompleteUpload* parts)
@@ -6461,43 +6475,6 @@ void RGWCompleteMultipart::complete()
64616475
}
64626476
}
64636477

6464-
if (op_ret >= 0 && target_obj.get() != nullptr) {
6465-
s->object->set_attrs(target_obj->get_attrs());
6466-
etag = s->object->get_attrs()[RGW_ATTR_ETAG].to_str();
6467-
// send request to notification manager
6468-
if (res.get() != nullptr) {
6469-
int ret = res->publish_commit(this, ofs, upload_time, etag, target_obj->get_instance());
6470-
if (ret < 0) {
6471-
ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
6472-
// too late to rollback operation, hence op_ret is not set here
6473-
}
6474-
} else {
6475-
ldpp_dout(this, 1) << "ERROR: reservation is null" << dendl;
6476-
}
6477-
} else {
6478-
ldpp_dout(this, 1) << "ERROR: either op_ret is negative (execute failed) or target_obj is null, op_ret: "
6479-
<< op_ret << dendl;
6480-
}
6481-
6482-
// remove the upload meta object ; the meta object is not versioned
6483-
// when the bucket is, as that would add an unneeded delete marker
6484-
// moved to complete to prevent segmentation fault in publish commit
6485-
if (meta_obj.get() != nullptr) {
6486-
int ret = meta_obj->delete_object(this, null_yield, rgw::sal::FLAG_PREVENT_VERSIONING);
6487-
if (ret >= 0) {
6488-
/* serializer's exclusive lock is released */
6489-
serializer->clear_locked();
6490-
} else {
6491-
ldpp_dout(this, 0) << "WARNING: failed to remove object " << meta_obj << ", ret: " << ret << dendl;
6492-
}
6493-
} else {
6494-
ldpp_dout(this, 0) << "WARNING: meta_obj is null" << dendl;
6495-
}
6496-
6497-
res.reset();
6498-
meta_obj.reset();
6499-
target_obj.reset();
6500-
65016478
send_response();
65026479
}
65036480

src/rgw/rgw_op.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,10 +1871,7 @@ class RGWCompleteMultipart : public RGWOp {
18711871
std::unique_ptr<rgw::sal::MPSerializer> serializer;
18721872
jspan_ptr multipart_trace;
18731873
ceph::real_time upload_time;
1874-
std::unique_ptr<rgw::sal::Object> target_obj;
18751874
std::unique_ptr<rgw::sal::Notification> res;
1876-
std::unique_ptr<rgw::sal::Object> meta_obj;
1877-
off_t ofs = 0;
18781875

18791876
public:
18801877
RGWCompleteMultipart() {}

0 commit comments

Comments
 (0)