Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(issues1171): improve objects deletion performance #1173

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public void replay(RemoveS3ObjectRecord record) {
if (object != null) {
s3ObjectSize.addAndGet(-object.getObjectSize());
}
markDestroyedObjects.remove(record.objectId());
preparedObjects.remove(record.objectId());
}

Expand Down Expand Up @@ -300,23 +299,26 @@ public ControllerResult<Void> checkS3ObjectsLifecycle() {
}
// check the mark destroyed objects
List<String> requiredDeleteKeys = new LinkedList<>();
List<Long> notExistObjects = new LinkedList<>();
for (Long objectId : this.markDestroyedObjects) {
while (true) {
Long objectId = this.markDestroyedObjects.peek();
if (objectId == null) {
break;
}
S3Object object = this.objectsMetadata.get(objectId);
if (object == null) {
notExistObjects.add(objectId);
// markDestroyedObjects isn't Timeline structure, so it may contains dirty / duplicated objectId
this.markDestroyedObjects.poll();
continue;
}
if (object.getMarkDestroyedTimeInMs() + (this.config.objectRetentionTimeInSecond() * 1000L) < System.currentTimeMillis()) {
this.markDestroyedObjects.poll();
// exceed delete retention time, trigger the truly deletion
requiredDeleteKeys.add(object.getObjectKey());
} else {
// the following objects' mark destroyed time is not expired, so break the loop
break;
}
}
// markDestroyedObjects isn't Timeline structure, so it may contains dirty / duplicated objectId
notExistObjects.forEach(this.markDestroyedObjects::remove);

if (!requiredDeleteKeys.isEmpty()) {
this.lastCleanStartTimestamp = System.currentTimeMillis();
Expand All @@ -332,9 +334,10 @@ public ControllerResult<Void> checkS3ObjectsLifecycle() {
* @return the result of the generation, contains the records which should be applied to the raft.
*/
public ControllerResult<Void> notifyS3ObjectDeleted(List<Long> deletedObjectIds) {
List<ApiMessageAndVersion> records = deletedObjectIds.stream().filter(markDestroyedObjects::contains)
.map(objectId -> new ApiMessageAndVersion(new RemoveS3ObjectRecord()
.setObjectId(objectId), (short) 0)).collect(Collectors.toList());
List<ApiMessageAndVersion> records = deletedObjectIds
.stream()
.map(objectId -> new ApiMessageAndVersion(new RemoveS3ObjectRecord().setObjectId(objectId), (short) 0))
.collect(Collectors.toList());
return ControllerResult.of(records, null);
}

Expand Down
Loading