Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-6784

Exceptions are inhibited in oak-run compact

    XMLWordPrintableJSON

Details

    Description

      Exceptions thrown by oak-run compact are inhibited so the exit code of the command is not correct in case of error.

      Example:

      $ java -jar oak-run-1.7.8-R1809845.jar compact test-oak-run/
      Apache Jackrabbit Oak 1.7.8-R1809845
      Compacting test-oak-run-6.3.0
      With default access mode
          before
              Thu Oct 05 15:14:22 CEST 2017, journal.log
              Thu Oct 05 15:14:23 CEST 2017, data00000a.tar
              Thu Oct 05 15:14:23 CEST 2017, manifest
              Thu Oct 05 15:14:23 CEST 2017, repo.lock
          size 119.1 MB (119133142 bytes)
          -> compacting
      org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException: Using a too recent version of oak-segment-tar
      	at org.apache.jackrabbit.oak.segment.file.ManifestChecker.checkStoreVersion(ManifestChecker.java:81)
      	at org.apache.jackrabbit.oak.segment.file.ManifestChecker.checkManifest(ManifestChecker.java:70)
      	at org.apache.jackrabbit.oak.segment.file.ManifestChecker.checkAndUpdateManifest(ManifestChecker.java:51)
      	at org.apache.jackrabbit.oak.segment.file.FileStore.<init>(FileStore.java:191)
      	at org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.build(FileStoreBuilder.java:343)
      	at org.apache.jackrabbit.oak.segment.tool.Compact.newFileStore(Compact.java:165)
      	at org.apache.jackrabbit.oak.segment.tool.Compact.compact(Compact.java:135)
      	at org.apache.jackrabbit.oak.segment.tool.Compact.run(Compact.java:128)
      	at org.apache.jackrabbit.oak.run.SegmentTarUtils.compact(SegmentTarUtils.java:183)
      	at org.apache.jackrabbit.oak.run.CompactCommand.execute(CompactCommand.java:93)
      	at org.apache.jackrabbit.oak.run.Main.main(Main.java:49)
          after
              Thu Oct 05 15:14:22 CEST 2017, journal.log
              Thu Oct 05 15:14:23 CEST 2017, data00000a.tar
              Thu Oct 05 15:14:23 CEST 2017, manifest
              Thu Oct 05 15:14:23 CEST 2017, repo.lock
          size 119.1 MB (119133142 bytes)
          removed files []
          added files []
      Compaction succeeded in 211.9 ms (0s).
      

      A quick fix would be to wrap the exception into a RuntimeException:

      --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/Compact.java
      +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/Compact.java
      @@ -127,7 +127,7 @@ public class Compact implements Runnable {
               try {
                   compact();
               } catch (Exception e) {
      -            e.printStackTrace();
      +            throw new RuntimeException("Failed to run compact", e);
               }
           }
      

      Attachments

        Activity

          People

            frm Francesco Mari
            volteanu Valentin Olteanu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: