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 2012/08/30 22:18:28 UTC
svn commit: r1379117 -
/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
Author: andy
Date: Thu Aug 30 20:18:28 2012
New Revision: 1379117
URL: http://svn.apache.org/viewvc?rev=1379117&view=rev
Log:
JENA-308
Protected against junk file from old uncommitted transaction.
Modified:
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java?rev=1379117&r1=1379116&r2=1379117&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java Thu Aug 30 20:18:28 2012
@@ -65,6 +65,11 @@ public class NodeTableTrans implements N
this.base = sub ;
this.nodeIndex = nodeIndex ;
this.journalObjFile = objFile ;
+ // Clear bytes from an old run
+ // (a crash while writing means the old transaction did not commit
+ // any bytes in the file are junk)
+ // This is coupled to the fact the prepare phase does the actually data writing.
+ journalObjFile.truncate(0) ;
this.label = label ;
}
@@ -160,12 +165,10 @@ public class NodeTableTrans implements N
allocOffset = base.allocOffset().getId() ;
// base node table empty e.g. first use.
journalObjFileStartOffset = journalObjFile.length() ;
+ // Because the data is written in prepare, the journal of object data is
+ // always empty at the start of a transaction.
if ( journalObjFileStartOffset != 0 )
- {
warn(log, "%s journalStartOffset not zero: %d/0x%02X",txn.getLabel(), journalObjFileStartOffset, journalObjFileStartOffset) ;
- // repeat for debugging.
- journalObjFile.length() ;
- }
allocOffset += journalObjFileStartOffset ;
this.nodeTableJournal = new NodeTableNative(nodeIndex, journalObjFile) ;
@@ -300,7 +303,7 @@ public class NodeTableTrans implements N
long expected = base.allocOffset().getId() ;
long len = journalObjFile.length() ;
if ( expected != allocOffset )
- System.err.println("************* UNEXPECTED [1]") ;
+ warn(log, "Inconsistency: base.allocOffset() = "+expected+" : allocOffset = "+allocOffset) ;
long newbase = -1 ;
append() ; // Calls all() which does a buffer flish.