Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #257 from jecluis/wip-fix-820
Browse files Browse the repository at this point in the history
rgw/sfs: fail gracefully if objref not created
  • Loading branch information
jecluis authored Nov 23, 2023
2 parents 7793a7f + 15dba00 commit 70d8c11
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/rgw/driver/sfs/multipart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdio.h>
#include <unistd.h>

#include <filesystem>
#include <fstream>

#include "rgw/driver/sfs/fmt.h"
Expand Down Expand Up @@ -441,6 +442,14 @@ int SFSMultipartUploadV2::complete(
bucketref->get_bucket_id(), mp->object_name, e.what()
)
<< dendl;
std::filesystem::remove(objpath, ec);
return -ERR_INTERNAL_ERROR;
}
if (!objref) {
// We were unable to create a version, but this might very well have been
// because we conflicted with another in-flight transaction. Lets return
// back to the user, and they can complete it again if they so desire.
std::filesystem::remove(objpath, ec);
return -ERR_INTERNAL_ERROR;
}
auto destpath = store->get_data_path() / objref->get_storage_path();
Expand All @@ -456,6 +465,7 @@ int SFSMultipartUploadV2::complete(
destpath, ec.message()
)
<< dendl;
std::filesystem::remove(objpath, ec);
return -ERR_INTERNAL_ERROR;
}

Expand All @@ -467,6 +477,7 @@ int SFSMultipartUploadV2::complete(
objpath, destpath, cpp_strerror(errno)
)
<< dendl;
std::filesystem::remove(objpath, ec);
return -ERR_INTERNAL_ERROR;
}

Expand Down Expand Up @@ -499,7 +510,9 @@ int SFSMultipartUploadV2::complete(
.delete_at = ceph::real_time()}
);
try {
objref->metadata_finish(store, bucketref->get_info().versioning_enabled());
res = objref->metadata_finish(
store, bucketref->get_info().versioning_enabled()
);
} catch (const std::system_error& e) {
lsfs_err(dpp) << fmt::format(
"failed to update db object {}: {}", objref->name,
Expand All @@ -508,6 +521,11 @@ int SFSMultipartUploadV2::complete(
<< dendl;
return -ERR_INTERNAL_ERROR;
}
if (!res) {
lsfs_err(dpp) << fmt::format("failed to update db object {}", objref->name)
<< dendl;
return -ERR_INTERNAL_ERROR;
}

// mark multipart upload done
res = mpdb.mark_done(upload_id);
Expand Down

0 comments on commit 70d8c11

Please sign in to comment.