Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -81,6 +81,7 @@ public abstract class AbstractKeyDeletingService extends BackgroundService
private final AtomicLong movedDirsCount;
private final AtomicLong movedFilesCount;
private final AtomicLong runCount;
private final AtomicLong callId;
Comment thread
jojochuang marked this conversation as resolved.
private final BootstrapStateHandler.Lock lock =
new BootstrapStateHandler.Lock();

Expand All @@ -97,6 +98,7 @@ public AbstractKeyDeletingService(String serviceName, long interval,
this.runCount = new AtomicLong(0);
this.metrics = ozoneManager.getDeletionMetrics();
this.perfMetrics = ozoneManager.getPerfMetrics();
this.callId = new AtomicLong(0);
}

protected int processKeyDeletes(List<BlockGroup> keyBlocksList,
Expand Down Expand Up @@ -220,7 +222,7 @@ private int submitPurgeKeysRequest(List<DeleteBlockGroupResult> results,

// Submit PurgeKeys request to OM
try {
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, runCount.get());
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, callId.incrementAndGet());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So the problem is in each run there can be multiple unique key deletion requests, so it can't use runCount as call id otherwise only one will execute and the rest will be regarded as retry and skipped.

} catch (ServiceException e) {
LOG.error("PurgeKey request failed. Will retry at next run.", e);
return 0;
Expand Down Expand Up @@ -250,7 +252,7 @@ private void addToMap(Map<Pair<String, String>, List<String>> map, String object

protected void submitPurgePaths(List<PurgePathRequest> requests,
String snapTableKey,
UUID expectedPreviousSnapshotId, long rnCnt) {
UUID expectedPreviousSnapshotId) {
OzoneManagerProtocolProtos.PurgeDirectoriesRequest.Builder purgeDirRequest =
OzoneManagerProtocolProtos.PurgeDirectoriesRequest.newBuilder();

Expand All @@ -275,7 +277,7 @@ protected void submitPurgePaths(List<PurgePathRequest> requests,

// Submit Purge paths request to OM
try {
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, rnCnt);
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, callId.incrementAndGet());
} catch (ServiceException e) {
LOG.error("PurgePaths request failed. Will retry at next run.", e);
}
Expand Down Expand Up @@ -403,7 +405,7 @@ public void optimizeDirDeletesAndSubmitRequest(
}

if (!purgePathRequestList.isEmpty()) {
submitPurgePaths(purgePathRequestList, snapTableKey, expectedPreviousSnapshotId, rnCnt);
submitPurgePaths(purgePathRequestList, snapTableKey, expectedPreviousSnapshotId);
}

if (dirNum != 0 || subDirNum != 0 || subFileNum != 0) {
Expand Down Expand Up @@ -613,6 +615,10 @@ public AtomicLong getRunCount() {
return runCount;
}

public AtomicLong getCallId() {
return callId;
}
Comment thread
swamirishi marked this conversation as resolved.
Outdated

/**
* Returns the number of dirs deleted by the background service.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ private void submitSnapshotMoveDeletedKeys(SnapshotInfo snapInfo,

private void submitRequest(OMRequest omRequest) {
try {
Status status =
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, getRunCount().get()).getStatus();
Status status = OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId,
getCallId().incrementAndGet()).getStatus();
if (!Objects.equals(status, Status.OK)) {
LOG.error("Request: {} failed with an status: {}. Will retry in the next run.", omRequest, status);
}
Expand Down