You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2017/08/13 13:36:47 UTC

[3/4] jena git commit: JENA-1379: Check for old-style dat-jrnl files

JENA-1379: Check for old-style dat-jrnl files


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/afc9b8c0
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/afc9b8c0
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/afc9b8c0

Branch: refs/heads/master
Commit: afc9b8c038eff18c3654d47e112a33b3a653f66f
Parents: 3d406fe
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Aug 5 21:48:22 2017 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Aug 5 22:18:56 2017 +0100

----------------------------------------------------------------------
 .../jena/tdb/transaction/JournalControl.java    | 36 +++++++++++---------
 1 file changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/afc9b8c0/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
index 03a5d32..748149e 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/JournalControl.java
@@ -85,11 +85,9 @@ public class JournalControl
         if ( journal == null || journal.isEmpty() )
             return ;
         
-        for ( FileRef fileRef : dsg.getConfig().objectFiles.keySet() )
-            recoverNodeDat(dsg, fileRef) ;
         recoverFromJournal(dsg.getConfig(), journal) ;
         
-        journal.close() ;
+        journal.close();
         // Recovery complete.  Tidy up.  Node journal files have already been handled.
         if ( journal.getFilename() != null )  
         {
@@ -120,6 +118,9 @@ public class JournalControl
     {
         if ( jrnl.isEmpty() )
             return false ;
+        
+        for ( FileRef fileRef : sConf.objectFiles.keySet() )
+            recoverNodeDat(sConf.location, fileRef) ;
 
         long posn = 0 ;
         for ( ;; )
@@ -194,20 +195,23 @@ public class JournalControl
      *  Node data files are append-only so recovering.
      *  This code is only for ObjectFileTransComplex.
      */
-    private static void recoverNodeDat(DatasetGraphTDB dsg, FileRef fileRef)
+    private static void recoverNodeDat(Location loc, FileRef fileRef)
     {
-//        // See DatasetBuilderTxn - same name generation code.
-//        String objFilename = fileRef.getFilename()+"-"+Names.extJournal ;
-//        objFilename = dsg.getLocation().absolute(objFilename) ;
-//        File jrnlFile = new File(objFilename) ;
-//        if ( jrnlFile.exists() && jrnlFile.length() > 0 )
-//        {
-//            syslog.info("Clearing node data: "+fileRef.getFilename()) ;
-//            ObjectFile dataJrnl = FileFactory.createObjectFileDisk(objFilename) ;
-//            dataJrnl.truncate(0);
-//        }
-//        if ( jrnlFile.exists() )
-//            FileOps.delete(objFilename) ;
+        // See DatasetBuilderTxn (Jena 3.4.0 or earlier) - same name generation code.
+        String objFilename = fileRef.getFilename()+"-"+Names.extJournal ;
+        objFilename = loc.absolute(objFilename) ;
+        File jrnlFile = new File(objFilename) ;
+        if ( jrnlFile.exists() ) {
+            if ( jrnlFile.length() > 0 ) {
+                syslog.info("Found dat-jrnl file : earlier version of Jena"+fileRef.getFilename()) ;
+                syslog.info("  To clearup: run TDB from a version of Jena 3.0.0-3.4.0");
+                syslog.info("  dat-jrnl should then go away");
+                syslog.info("  See https://issues.apache.org/jira/browse/JENA-1379");
+                throw new TDBException("Manual recovery required - see log - see JENA-1379 <https://issues.apache.org/jira/browse/JENA-1379>");
+            }
+            //Empty - nothing to do anyway - clearup.
+            FileOps.delete(objFilename) ;
+        }
     }
     
     public static void replay(Transaction transaction)