ctubbsii commented on a change in pull request #541: fixes #538 fix WAL 
recovery code
URL: https://github.com/apache/accumulo/pull/541#discussion_r197557529
 
 

 ##########
 File path: 
server/tserver/src/main/java/org/apache/accumulo/tserver/log/SortedLogRecovery.java
 ##########
 @@ -190,38 +189,29 @@ private long findLastStartToFinish(List<Path> 
recoveryLogs, Set<String> tabletFi
           lastStart = key.seq;
           lastStartFile = key.filename;
         } else if (key.event == COMPACTION_FINISH) {
-          if (lastEvent == null) {
-            firstEventWasFinish = true;
-          } else if (lastEvent == COMPACTION_FINISH) {
-            throw new IllegalStateException(
-                "Saw consecutive COMPACTION_FINISH events " + key.tabletId + " 
" + key.seq);
-          } else {
-            if (key.seq <= lastStart) {
-              throw new IllegalStateException(
-                  "Compaction finish <= start " + lastStart + " " + key.seq);
-            }
-            recoverySeq = lastStart;
-            lastStartFile = null;
-            sawStartFinish = true;
-          }
+          checkState(key.seq >= lastFinish); // should only fail if bug 
elsewhere
+          checkState(key.seq > lastStart, "Compaction finish <= start %s %s 
%s", key.tabletId,
+              key.seq, lastStart);
+          checkState(lastEvent == null || lastEvent == COMPACTION_START,
+              "Saw consecutive COMPACTION_FINISH events %s %s %s", 
key.tabletId, lastFinish,
+              key.seq);
+          lastFinish = key.seq;
         } else {
           throw new IllegalStateException("Non compaction event seen " + 
key.event);
         }
 
         lastEvent = key.event;
       }
 
-      if (firstEventWasFinish && !sawStartFinish) {
-        throw new IllegalStateException("COMPACTION_FINISH (without preceding 
COMPACTION_START)"
-            + " is not followed by a successful minor compaction.");
-      }
-
-      if (lastStartFile != null && 
suffixes.contains(getPathSuffix(lastStartFile))) {
-        // There was no compaction finish event, however the last compaction 
start event has a file
-        // in the metadata table, so the compaction finished.
+      if (lastStart > lastFinish && lastStartFile != null
+          && suffixes.contains(getPathSuffix(lastStartFile))) {
+        // There was no compaction finish event following this start, however 
the last compaction
+        // start event has a file in the metadata table, so the compaction 
finished.
         log.debug("Considering compaction start {} {} finished because file {} 
in metadata table",
             tabletId, lastStart, getPathSuffix(lastStartFile));
         recoverySeq = lastStart;
+      } else {
+        recoverySeq = Math.max(0, lastFinish - 1);
 
 Review comment:
   This else statement covers the case where `lastEvent == COMPACTION_FINISH` 
(last successful event anyway...). That could be more clear in a comment. Also, 
would be good to mention why `lastFinish - 1` is used here (because that's the 
sequence id for the `COMPACTION_START` which corresponds to this 
`COMPACTION_FINISH`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to