smengcl commented on code in PR #4360:
URL: https://github.com/apache/ozone/pull/4360#discussion_r1136392963


##########
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:
   The diff is a "read" operation from client's perspective, while we are 
actually writing data in OM background. This request would presumably be served 
by one of the threads in OM thread pool. And it isn't serialized by Ratis or 
anything else.
   
   We might need to have a synchronization mechanism here. Otherwise, two 
requests with the same from/to snapshot could reach OM at the same time and 
potentially both could reach this line.



-- 
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]

Reply via email to