smengcl commented on code in PR #4360:
URL: https://github.com/apache/ozone/pull/4360#discussion_r1137815700
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -131,80 +171,124 @@ private DifferSnapshotInfo getDSIFromSI(SnapshotInfo
snapshotInfo,
getTablePrefixes(snapshotOMMM, volumeName, bucketName));
}
- @SuppressWarnings("checkstyle:methodlength")
+ @SuppressWarnings("parameternumber")
public SnapshotDiffReport getSnapshotDiffReport(final String volume,
final String bucket,
final OmSnapshot
fromSnapshot,
final OmSnapshot toSnapshot,
final SnapshotInfo fsInfo,
- final SnapshotInfo tsInfo)
+ final SnapshotInfo tsInfo,
+ final int index,
+ final int pageSize)
throws IOException, RocksDBException {
+ String diffJobKey = fsInfo.getSnapshotID() + DELIMITER +
+ tsInfo.getSnapshotID();
+
+ Pair<String, Boolean> jobIdToJobExist = getOrCreateJobId(diffJobKey);
+ String jobId = jobIdToJobExist.getLeft();
+ boolean jobExist = jobIdToJobExist.getRight();
+
+ // If snapshot diff doesn't exist, we generate the diff report first
+ // and add it to the table for future requests.
+ // This needs to be updated to queuing and job status base.
+ if (!jobExist) {
+ generateSnapshotDiffReport(jobId, volume, bucket, fromSnapshot,
+ toSnapshot, fsInfo, tsInfo);
Review Comment:
`getOrCreateJobId()` itself is synchronized but the issue (race condition)
can still exist.
Essentially two requests (two separate threads in OM request handler thread
pool) can still interleave and reach `getOrCreateJobId` at around the same
time. Where they can both get `jobExist == false` and proceed to call
`generateSnapshotDiffReport()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]