-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Enhancement] Support Async delete files from Recycle Bin in shared data mode #50636
Conversation
}, LakeTableHelper.ASYNC_REMOVE_PARTITION_EXECUTOR)); | ||
} | ||
} | ||
|
||
public static boolean isSharedPartitionDirectory(PhysicalPartition partition, long warehouseId) throws StarClientException { | ||
ShardInfo shardInfo = getAssociatedShardInfo(partition, warehouseId).orElse(null); | ||
if (shardInfo == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
Concurrency issue with RUNNING_DELETE_TABLE
map.
You can modify the code like this:
static boolean submitAndCheckAsyncDeleteTableFromRecycleBin(long dbId, OlapTable table) {
Preconditions.checkState(table.isCloudNativeTableOrMaterializedView());
table.removeTableBinds(false);
RUNNING_DELETE_TABLE.computeIfAbsent(table, key -> new LakeTableCleaner(table, Lists.newArrayList()));
LakeTableCleaner cleaner = RUNNING_DELETE_TABLE.get(table);
// return false if submit failed or some of the deletion task has been failed.
boolean succ = cleaner.submitAndCheckAsyncCleanTable();
if (succ) {
table.removeTabletsFromInvertedIndex();
}
return succ;
}
} | ||
}); | ||
return allSuccessed; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
In the checkAllAsyncDeleteSuccessed
method, clearing asyncDeleteReturn
within the stream operation can cause a ConcurrentModificationException
.
You can modify the code like this:
protected static boolean checkAllAsyncDeleteSuccessed(List<CompletableFuture<Boolean>> asyncDeleteReturn) {
boolean allSuccessed = false;
List<CompletableFuture<Boolean>> toBeRetried = new ArrayList<>();
allSuccessed = asyncDeleteReturn.stream().allMatch(future -> {
try {
return future != null && future.isDone() && future.get();
} catch (Exception e) {
// add to list for retrying later if any exception is thrown
toBeRetried.add(future);
return false;
}
});
asyncDeleteReturn.clear();
asyncDeleteReturn.addAll(toBeRetried);
return allSuccessed;
}
} | ||
} | ||
|
||
return checkAllAsyncDeleteSuccessed(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
Potential non-thread-safe access to asyncDeleteReturn
You can modify the code like this:
private final List<CompletableFuture<Boolean>> asyncDeleteReturn = Collections.synchronizedList(new ArrayList<>());
// And make sure other accesses to asyncDeleteReturn are synchronized properly.
// This method ensures thread-safe access when checking if all async deletions succeeded
private boolean checkAllAsyncDeleteSuccessed() {
synchronized (asyncDeleteReturn) {
return asyncDeleteReturn.stream().allMatch(future -> {
try {
return future != null && future.isDone() && future.get();
} catch (Exception e) {
// re-submit in the future if any exception is thrown
asyncDeleteReturn.clear();
return false;
}
});
}
}
e07bb9f
to
01eef89
Compare
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
…ata mode Support Async delete files from Recycle Bin in shared data mode to avoid acquire lock for a long time. Signed-off-by: srlch <[email protected]>
fadc804
to
00cfe0d
Compare
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]❌ fail : 8 / 27 (29.63%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
Support Async delete files from Recycle Bin in shared data mode to avoid acquire lock for a long time.
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: