Skip to content

Commit

Permalink
Require oplog update only when archived
Browse files Browse the repository at this point in the history
An oplog update is only required when the object is archived, instead of
when lifecycle is enabled: so fix the condition to avoid extra
associated load.

The update is also required when bucket notification is enabled on the
bucket, no change there.

Issue: CLDSRV-563
  • Loading branch information
francoisferrand committed Dec 27, 2024
1 parent 4025eef commit 010aa77
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
18 changes: 11 additions & 7 deletions lib/api/apiUtils/object/deleteObject.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
/**
* _bucketRequiresOplogUpdate - DELETE an object from a bucket
* @param {BucketInfo} bucket - bucket object
* @param {ObjectMD} objMD - object metadata
* @param {BucketInfo} bucket - bucket info
* @return {boolean} whether objects require oplog updates on deletion, or not
*/
function _bucketRequiresOplogUpdate(bucket) {
function _deleteRequiresOplogUpdate(objMD, bucket) {
// If the object is archived, an oplog update is required
if (objMD.archive) {
return true;
}
// Default behavior is to require an oplog update
if (!bucket || !bucket.getLifecycleConfiguration || !bucket.getNotificationConfiguration) {
if (!bucket || !bucket.getNotificationConfiguration) {
return true;
}
// If the bucket has lifecycle configuration or notification configuration
// set, we also require an oplog update
return bucket.getLifecycleConfiguration() || bucket.getNotificationConfiguration();
// If the bucket has notification configuration set, we also require an oplog update
return bucket.getNotificationConfiguration();
}

module.exports = {
_bucketRequiresOplogUpdate,
_deleteRequiresOplogUpdate,
};
4 changes: 2 additions & 2 deletions lib/api/multiObjectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { hasGovernanceBypassHeader, checkUserGovernanceBypass, ObjectLockInfo }
const requestUtils = policies.requestUtils;
const { validObjectKeys } = require('../routes/routeVeeam');
const { deleteVeeamCapabilities } = require('../routes/veeam/delete');
const { _bucketRequiresOplogUpdate } = require('./apiUtils/object/deleteObject');
const { _deleteRequiresOplogUpdate } = require('./apiUtils/object/deleteObject');
const { overheadField } = require('../../constants');

const versionIdUtils = versioning.VersionID;
Expand Down Expand Up @@ -345,7 +345,7 @@ function getObjMetadataAndDelete(authInfo, canonicalID, request,
if (options && options.deleteData) {
options.overheadField = overheadField;
deleteInfo.deleted = true;
if (!_bucketRequiresOplogUpdate(bucket)) {
if (!_deleteRequiresOplogUpdate(objMD, bucket)) {
options.doesNotNeedOpogUpdate = true;
}
if (objMD.uploadId) {
Expand Down
4 changes: 2 additions & 2 deletions lib/api/objectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const monitoring = require('../utilities/monitoringHandler');
const { hasGovernanceBypassHeader, ObjectLockInfo }
= require('./apiUtils/object/objectLockHelpers');
const { config } = require('../Config');
const { _bucketRequiresOplogUpdate } = require('./apiUtils/object/deleteObject');
const { _deleteRequiresOplogUpdate } = require('./apiUtils/object/deleteObject');

const versionIdUtils = versioning.VersionID;
const objectLockedError = new Error('object locked');
Expand Down Expand Up @@ -182,7 +182,7 @@ function objectDeleteInternal(authInfo, request, log, isExpiration, cb) {
delOptions.replayId = objectMD.uploadId;
}

if (!_bucketRequiresOplogUpdate(bucketMD)) {
if (!_deleteRequiresOplogUpdate(objectMD, bucketMD)) {
delOptions.doesNotNeedOpogUpdate = true;
}

Expand Down

0 comments on commit 010aa77

Please sign in to comment.