jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1206863 - in /incubator/jena: Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/ Scratch/AFS/Jena-Dev/trunk/ Scratch/AFS/Jena-Dev/trunk/src/dev/
Date Sun, 27 Nov 2011 22:08:01 GMT
Author: andy
Date: Sun Nov 27 22:08:00 2011
New Revision: 1206863

URL: http://svn.apache.org/viewvc?rev=1206863&view=rev
Log:
Debug for J-163

Added:
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/dwimall   (with props)
Modified:
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java?rev=1206863&r1=1206862&r2=1206863&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
Sun Nov 27 22:08:00 2011
@@ -299,6 +299,8 @@ public class TransactionManager
         // entry synchronized part
         return begin$(mode, label) ;
     }
+    
+    public static boolean tmpDebugNoteBegin = false ; 
         
     synchronized
     private DatasetGraphTxn begin$(ReadWrite mode, String label)
@@ -315,13 +317,25 @@ public class TransactionManager
         if ( mode == ReadWrite.WRITE && activeWriters.get() > 0 )    // Guard
             throw new TDBTransactionException("Existing active write transaction") ;
 
+        if ( tmpDebugNoteBegin ) 
+            switch ( mode )
+            {
+                case READ : System.out.print("r") ; break ;
+                case WRITE : System.out.print("w") ; break ;
+            }
+        
         // Even flush queue here.
         
         DatasetGraphTDB dsg = baseDataset ;
         // *** But, if there are pending, committed transactions, use latest.
         if ( ! commitedAwaitingFlush.isEmpty() )
+        {  if ( tmpDebugNoteBegin ) System.out.print('x') ;
             dsg = commitedAwaitingFlush.get(commitedAwaitingFlush.size()-1).getActiveDataset()
;
-        
+        }
+        else 
+        {
+            if ( tmpDebugNoteBegin ) System.out.print('_') ;
+        }
         Transaction txn = createTransaction(dsg, mode, label) ;
         DatasetGraphTxn dsgTxn = (DatasetGraphTxn)new DatasetBuilderTxn(this).build(txn,
mode, dsg) ;
         txn.setActiveDataset(dsgTxn) ;

Added: incubator/jena/Scratch/AFS/Jena-Dev/trunk/dwimall
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/dwimall?rev=1206863&view=auto
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/dwimall (added)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/dwimall Sun Nov 27 22:08:00 2011
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+rm -rf LOG
+
+for n in $(nums 1 20)
+do
+    dwim 2>&1 | tee --append LOG
+    done

Propchange: incubator/jena/Scratch/AFS/Jena-Dev/trunk/dwimall
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java?rev=1206863&r1=1206862&r2=1206863&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java Sun Nov
27 22:08:00 2011
@@ -18,6 +18,7 @@
 
 package dev ;
 
+import static java.lang.Math.* ;
 import static com.hp.hpl.jena.tdb.transaction.TransTestLib.count ;
 import static java.lang.String.format ;
 
@@ -45,6 +46,7 @@ import com.hp.hpl.jena.sparql.sse.SSE ;
 import com.hp.hpl.jena.tdb.ConfigTest ;
 import com.hp.hpl.jena.tdb.DatasetGraphTxn ;
 import com.hp.hpl.jena.tdb.StoreConnection ;
+import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.base.block.FileMode ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
 import com.hp.hpl.jena.tdb.sys.SystemTDB ;
@@ -74,33 +76,41 @@ public class Jena163_TDBDifferentIds
     
     static boolean MEM                          = false ;
     
-    static final Location LOC                   = MEM ? Location.mem() : new Location(ConfigTest.getTestingDirDB())
;
-    static final int Iterations                 = MEM ? 1000 : 1000 ;
+    static /*final*/ Location LOC                   = MEM ? Location.mem() : new Location(ConfigTest.getTestingDirDB())
;
+    static final int Iterations                 = MEM ? 10000 : 10000 ;
     // Output style.
     static boolean logging                      = false ;
     
     // XXX Switch to threads choosing a mix of actions. 
     
-    static final int numReaderTasks             = 5 ;   // 5
-    static final int numWriterTasksA            = 3 ;   // 3
-    static final int numWriterTasksC            = 5 ;   // 5
+    static final int numReaderTasks             = 8 ;   // 5
+    static final int numWriterTasksA            = 4 ;   // 3
+    static final int numWriterTasksC            = 8 ;   // 5
 
-    static final int readerSeqRepeats           = 8 ;   // 8
+    static final int readerSeqRepeats           = 4 ;   // 8
     static final int readerMaxPause             = 20 ;  // 20
 
     static final int writerAbortSeqRepeats      = 3 ;   // 4
     static final int writerCommitSeqRepeats     = 4 ;   // 4
     static final int writerMaxPause             = 20 ;  // 20
 
-    static final int numThreadsInPool           = 6 ;           // If <= 0 then use an
unbounded thread pool.   
+    static final int numThreadsInPool           = 4 ;           // If <= 0 then use an
unbounded thread pool.   
     private static ExecutorService execService  = null ;
     
     private static int iteration                = 0 ;
     private static int numIterationsPerBlock    = 100 ;
     private static int colCount                 = 0 ;
     private static int colMax                   = 200 ;
-    private static boolean inlineProgress       = true ;   // Set true so that every transaction
print a letter for what it does. 
-    private static Semaphore startPoint ;  
+    private static boolean inlineProgress       = true ;   // Set true so that every transaction
print a letter for what it does.
+    
+    static {
+        TransactionManager.tmpDebugNoteBegin = inlineProgress ; 
+    }
+    
+    // Queue treads starting
+    private static Semaphore startPoint ;
+    // Queue threads finishing.
+    private static CountDownLatch doneSignal ;
 
     /** TODO
      * Ideally: better mixes of R, C and A.
@@ -131,8 +141,18 @@ public class Jena163_TDBDifferentIds
                 ? Executors.newFixedThreadPool(numThreadsInPool)
                 : Executors.newCachedThreadPool() ;
             
-            startTestIteration() ;                
-            new Jena163_TDBDifferentIds().manyReaderAndOneWriter() ;
+            startTestIteration() ;         
+            
+            try {
+                new Jena163_TDBDifferentIds().manyReaderAndOneWriter() ;
+            } catch (TDBException ex)
+            {
+                System.err.println() ;
+                ex.printStackTrace(System.err) ;
+                System.err.println() ;
+            }
+            
+            // Should already be shutdown.
             execService.shutdown() ;
             if ( ! execService.awaitTermination(30, TimeUnit.SECONDS) )
                 System.err.println("Shutdown didn't complete in time") ;
@@ -146,13 +166,6 @@ public class Jena163_TDBDifferentIds
             println("FINISH") ;
     }
     
-    private static void clean()
-    {
-        StoreConnection.release(LOC) ;
-        if ( ! LOC.isMem() )
-            FileOps.clearDirectory(LOC.getDirectoryPath()) ;
-    }
-
     static class Reader implements Callable<Object>
     {
         private final int repeats ;
@@ -199,13 +212,13 @@ public class Jena163_TDBDifferentIds
                         describeWithAbort(qs2, dsg, -1) ;
                     } catch (QueryCancelledException e) 
                     { 
-                        txn("C");
+                        txn("X", dsg);
                     }
 
                     log.debug("reader finish " + id + "/" + i) ;
                     dsg.end() ;
+                    txn("R", dsg) ;
                     dsg = null ;
-                    txn("R") ;
                 }
                 return null ;
             } catch (RuntimeException ex)
@@ -215,11 +228,12 @@ public class Jena163_TDBDifferentIds
                 {
                     dsg.abort() ;
                     dsg.end() ;
+                    txn("E", dsg) ;
                     dsg = null ;
-                    txn("E") ;
                 }
                 return null ;
             }
+            finally { doneSignal.countDown(); }
         }
     }
 
@@ -305,12 +319,12 @@ public class Jena163_TDBDifferentIds
                     if (commit) 
                     {
                         dsg.commit() ;
-                        txn("C") ;
+                        txn("C", dsg) ;
                     }
                     else
                     {
                         dsg.abort() ;
-                        txn("A") ;
+                        txn("A", dsg) ;
                     }
                     SysTxnState state = sConn.getTransMgrState() ;
                     log.debug(state.toString()) ;
@@ -322,6 +336,7 @@ public class Jena163_TDBDifferentIds
             }
             catch (RuntimeException ex)
             { 
+                txn("E", dsg) ;
                 ex.printStackTrace(System.err) ;
                 System.exit(1) ;
                 if ( dsg != null )
@@ -330,8 +345,10 @@ public class Jena163_TDBDifferentIds
                     dsg.end() ;
                     dsg = null ;
                 }
+                
                 return null ;
             }
+            finally { doneSignal.countDown(); }
         }
     
         // return the delta.
@@ -366,9 +383,22 @@ public class Jena163_TDBDifferentIds
     @AfterClass 
     public static void afterClass() {}
 
+    private static void clean()
+    {
+        StoreConnection.release(LOC) ;
+        if ( ! LOC.isMem() )
+        {
+            FileOps.clearDirectory(LOC.getDirectoryPath()) ;
+            // Clean because it's new.
+            //LOC = new Location(ConfigTest.getTestingDirUnique()) ;
+        }
+    }
+
     private StoreConnection sConn ;
     protected synchronized StoreConnection getStoreConnection()
     {
+        
+        
         StoreConnection sConn = StoreConnection.make(LOC) ;
         //sConn.getTransMgr().recording(true) ;
         return sConn ;
@@ -422,35 +452,48 @@ public class Jena163_TDBDifferentIds
         // That can lead to uninterstin sequences of actions. 
         startPoint = null ; //new Semaphore(0) ;
 
-        int RN1 = numReaderTasks/2 ;
-        int RN2 = Math.min(1, numReaderTasks) ;
-        int RN3 = Math.max(numReaderTasks - RN1 - RN2,0);
+        int RN1 = 2 ;
+        int RN2 = min(1, numReaderTasks) ;
+        int RN3 = max(numReaderTasks - RN1 - RN2,0);
 
         int WC1 =  numWriterTasksC/2 ;
-        int WC2 =  numWriterTasksC - WC1 ;
+        int WC2 =  2 ;
+        int WC3 =  numWriterTasksC - WC1 - WC2 ;
         
         int WA1 =  numWriterTasksA/2 ;
         int WA2 =  numWriterTasksA - WA1 ;
         
+        //System.out.println(RN1 + " " + RN2 + " " + RN3 + " " + WC1 + " " + WC2 + " " +
WA1 + " " + WA2) ;
+        int N = max(RN1,0) + max(RN2,0) + max(RN3,0) + max(WC1,0) + max(WC2,0) + max(WA1,0)
+ max(WA2,0) ;
+        //System.out.println(N) ;
+        doneSignal = new CountDownLatch(N) ;
+        
         // Define the query mix.
         submit(execService, procW_c, WC1, "COMMIT-") ;
         submit(execService, procW_a, WA1, "ABORT-") ;
         submit(execService, procR,   RN1, "READ-") ;
         submit(execService, procW_c, WC2, "COMMIT-") ;
         submit(execService, procR,   RN2, "READ-") ;
-//        submit(execService, procR,   RN3, "READ-") ;
-//        submit(execService, procW_c, WA2, "ABORT-") ;
-        submit(execService, procW_c, WA2, "ABORT-") ;
+        submit(execService, procW_a, WA2, "ABORT-") ;
         submit(execService, procR,   RN3, "READ-") ;
+        submit(execService, procW_c, WC3, "COMMIT-") ;
         
         if ( startPoint != null )
             // Let them all go.
             startPoint.release(4000) ;
-        
-        try
-        {
+
+        // Wait until all done.
+        try { doneSignal.await() ; }
+        catch (InterruptedException e) { e.printStackTrace(System.err) ; }
+        
+        try { 
+            // This is an orderly shutdown so followed by the awaitTermination
+            // shoudl wait for all threads, making the CountDownLatch unnecessary.
+            // CountDownLatch added as a precaution while searching for JENA-163
+            // which seems to see occasional uncleared out node journal files.
             execService.shutdown() ;
-            execService.awaitTermination(100, TimeUnit.SECONDS) ;
+            if ( ! execService.awaitTermination(100, TimeUnit.SECONDS) )
+                System.err.println("Bad shutdown") ;
         } catch (InterruptedException e)
         {
             e.printStackTrace(System.err) ;
@@ -516,12 +559,13 @@ public class Jena163_TDBDifferentIds
         return new Quad(g,s,p,o) ;
     }
 
-    private static void txn(String label)
+    static void txn(String label, DatasetGraphTxn dsg )
     {
         if ( ! inlineProgress )
             return ;
         checkCol() ;
         print(label) ;
+        //print("["+dsg.getTransaction().getTxnId()+"]") ;
         colCount += label.length() ;
     }
 

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java?rev=1206863&r1=1206862&r2=1206863&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java Sun Nov 27 22:08:00 2011
@@ -22,11 +22,13 @@ import java.io.FileInputStream ;
 import java.io.InputStream ;
 
 import org.junit.Test ;
+import org.openjena.atlas.iterator.Iter ;
 import org.openjena.atlas.lib.FileOps ;
 import org.openjena.atlas.lib.Lib ;
 import org.openjena.atlas.logging.Log ;
 import arq.update ;
 
+import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.query.Dataset ;
 import com.hp.hpl.jena.query.Query ;
 import com.hp.hpl.jena.query.QueryCancelledException ;
@@ -37,6 +39,7 @@ import com.hp.hpl.jena.query.QueryFactor
 import com.hp.hpl.jena.query.QuerySolution ;
 import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.query.ResultSet ;
+import com.hp.hpl.jena.sparql.core.Quad ;
 import com.hp.hpl.jena.sparql.function.FunctionRegistry ;
 import com.hp.hpl.jena.sparql.function.library.wait ;
 import com.hp.hpl.jena.sparql.lang.SyntaxVarScope ;
@@ -56,6 +59,43 @@ public class Run extends RunBase
     
     public static void main(String[] argv) throws Exception
     {
+        // w_rCwxRCw_
+        Quad quad1 = SSE.parseQuad("(_ <s> <p> 1)") ;
+        Quad quad2 = SSE.parseQuad("(_ <s> <p> 2)") ;
+        Quad quad3 = SSE.parseQuad("(_ <s> <p> 3)") ;
+        
+        String DIR = "DB" ;
+        FileOps.clearDirectory(DIR) ;
+        
+        StoreConnection sConn = StoreConnection.make(DIR) ;
+        DatasetGraphTxn txnW1 = sConn.begin(ReadWrite.WRITE) ;
+        txnW1.add(quad1) ;
+        
+        DatasetGraphTxn txnR1 = sConn.begin(ReadWrite.READ) ;
+        txnW1.commit() ; System.out.print("C") ;
+        
+        
+        Iter.consume(txnR1.find()) ;        // Before / after?
+        
+        txnW1.end() ;
+        
+        DatasetGraphTxn txnW2 = sConn.begin(ReadWrite.WRITE) ;
+        txnW2.add(quad2) ;
+
+        txnR1.end() ; System.out.print("R") ;
+        txnW2.commit() ;  System.out.print("C") ;
+        
+        DatasetGraphTxn txnW3 = sConn.begin(ReadWrite.WRITE) ;
+        txnW3.add(quad3) ;
+        txnW3.commit() ; System.out.print("C") ;
+
+        System.out.println(sConn.getBaseDataset()) ;
+        exit(0) ;
+        
+        
+        
+        
+        
         if ( true )
         {
             // And TDBFactory.create



Mime
View raw message