Skip to content

Commit

Permalink
Fix handling of archived object replacement
Browse files Browse the repository at this point in the history
- The `delete` oplog entry must not be generated when putObject is used
to restore the object: otherwise a GC request will be sent to cold
backend, and the object will never be expired.
- The `originOp` of the (new) metadata should not be affected:
"s3:ReplaceArchivedObject" should only be set on the extra `delete` op
in the oplog.

Issue: CLDSRV-560
  • Loading branch information
francoisferrand committed Sep 6, 2024
1 parent 055f9f4 commit 9f95637
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/api/apiUtils/object/createAndStoreObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ function createAndStoreObject(bucketName, bucketMD, objectKey, objMD, authInfo,
metadataStoreParams.oldReplayId = objMD.uploadId;
}

if (objMD && !bucketMD.isVersioningEnabled() && objMD?.archive?.archiveInfo) {
metadataStoreParams.needOplogUpdate = true;
metadataStoreParams.originOp = 's3:ReplaceArchivedObject';
}

/* eslint-disable camelcase */
const dontSkipBackend = externalBackends;
/* eslint-enable camelcase */
Expand Down Expand Up @@ -273,6 +268,9 @@ function createAndStoreObject(bucketName, bucketMD, objectKey, objMD, authInfo,
if (isPutVersion) {
const options = overwritingVersioning(objMD, metadataStoreParams);
return process.nextTick(() => next(null, options, infoArr));
} else if (!bucketMD.isVersioningEnabled() && objMD?.archive?.archiveInfo) {
// Ensure we trigger a "delete" event in the oplog for the previously archived object
metadataStoreParams.needOplogUpdate = 's3:ReplaceArchivedObject';
}
return versioningPreprocessing(bucketName, bucketMD,
metadataStoreParams.objectKey, objMD, log, (err, options) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const services = {
}
if (needOplogUpdate) {
options.needOplogUpdate = true;
options.originOp = originOp;
options.originOp = needOplogUpdate;
}
if (uploadId) {
md.setUploadId(uploadId);
Expand Down

0 comments on commit 9f95637

Please sign in to comment.