jojochuang commented on code in PR #11808:
URL: https://github.com/apache/ozone/pull/11808#discussion_r4395659912


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -799,13 +802,19 @@ Pair<List<DiffReportEntry>, String> createPageResponse(
    */
   @VisibleForTesting
   void checkReportsIntegrity(final SnapshotDiffJob diffJob,
+                             final String jobKey,
                              final String largestPageIndex,
                              boolean lastPage) throws IOException {
-    // For last page check last entry returned if the largest entry key equals 
the largest key stored in the job entry.
-    if (lastPage && (diffJob.getLargestEntryKey() == null || 
!diffJob.getLargestEntryKey().equals(largestPageIndex))) {
+    // A DONE job persisted before largestEntryKey was introduced deserializes 
with a
+    // null largestEntryKey. Such a legacy job carries no stored last-entry to 
compare,
+    // so skip the integrity assertion for it rather than treating it as a 
failure.
+    if (lastPage && diffJob.getLargestEntryKey() != null &&
+        !diffJob.getLargestEntryKey().equals(largestPageIndex)) {
       LOG.error("Expected last entry: {} but found " +
               "Largest Page entry: {}", diffJob.getLargestEntryKey(), 
largestPageIndex);
-      updateJobStatus(diffJob.getJobId(), DONE, FAILED);
+      // The job is stored under jobKey (fromSnapshotId + DELIMITER + 
toSnapshotId), not
+      // under its jobId; passing the jobId here would look up a missing row.
+      updateJobStatus(jobKey, DONE, FAILED);

Review Comment:
   Fixed in the latest commit. The integrity check now holds the manager lock 
and updates only a matching job ID in DONE status. Added regression cases for 
replacement DONE/IN_PROGRESS/QUEUED/FAILED jobs, an already-failed 
same-generation job, and a removed job. All 71 TestSnapshotDiffManager cases 
pass; checkstyle passes.



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