You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2021/04/27 09:08:43 UTC

[GitHub] [jena] rvesse commented on a change in pull request #988: [JENA-2096] Added ability to delete old DB after compaction has completed successfully

rvesse commented on a change in pull request #988:
URL: https://github.com/apache/jena/pull/988#discussion_r621015387



##########
File path: jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionCompact.java
##########
@@ -88,18 +88,25 @@ private static DatasetGraph unwrap(DatasetGraph dsg, Predicate<DatasetGraph> pre
     }
 
     static class CompactTask extends TaskBase {
-        static private Logger log = Fuseki.compactLog;
+        static private final Logger log = Fuseki.compactLog;
+
+        private final boolean shouldDeleteOld;
 
         public CompactTask(HttpAction action) {
             super(action);
+
+            String deleteOldParam = action.request.getParameter("deleteOld");
+
+            this.shouldDeleteOld = ( deleteOldParam != null
+                && ( deleteOldParam.isEmpty() || deleteOldParam.equalsIgnoreCase("true") ) );

Review comment:
       Makes sense but we should ensure that this is explicit in the documentation

##########
File path: jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseOps.java
##########
@@ -198,6 +198,12 @@ public static void compact(DatasetGraphSwitchable container) {
             LOG.debug(String.format("Compact %s -> %s\n", db1.getFileName(), db2.getFileName()));
 
             compact(container, loc1, loc2);
+
+            if ( shouldDeleteOld ) {
+                Path loc1Path = IOX.asPath(loc1);
+                LOG.info("Deleting old database after successful compaction (old db path='" + loc1Path + "'...");
+                IOX.delete(loc1Path);

Review comment:
       Does this suppress errors?
   
   Doing this on Windows has a good chance of failing due to the longstanding JVM bug with deleting memory mapped files




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org