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 2016/08/17 16:01:41 UTC
[08/11] jena git commit: Align to ThreadAction changes in Jena.
Align to ThreadAction changes in Jena.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f0d389d5
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f0d389d5
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f0d389d5
Branch: refs/heads/master
Commit: f0d389d5600f4a10ef6c10e352e13bb9de2dfe3c
Parents: 39a8c3e
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Aug 13 15:10:57 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Aug 14 20:22:12 2016 +0100
----------------------------------------------------------------------
.../apache/jena/tdb/transaction/TransactionManager.java | 11 ++++++-----
.../apache/jena/tdb/transaction/TestTransPromote.java | 5 +++--
2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f0d389d5/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
index efbc764..da98a92 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
@@ -339,16 +339,17 @@ public class TransactionManager
}
// Don't promote if the database has moved on.
+
// 1/ No active writers.
- // Ideally, wiait to see if it aborts but abort is uncommon.
+ // Ideally, wait to see if it aborts but abort is uncommon.
+ // We can not grab the write lock here - we have the TM sync lock
+ // so an active writer can not commit.s
+
// Easy implementation -- if any active writers, don't promote.
if ( activeWriters.get() > 0 )
- throw new TDBTransactionException("Dataset may be changing - active writer - can't promote") ;
-// // Would this block corrctly? ... drops the sync lock?
-// acquireWriterLock(true) ;
+ throw new TDBTransactionException("Dataset may be changing - active writer - can't promote") ;
// 2/ Check the database view has not moved on. No active writers at the moment.
-
if ( txn.getVersion() != version.get() )
throw new TDBTransactionException("Dataset changed - can't promote") ;
http://git-wip-us.apache.org/repos/asf/jena/blob/f0d389d5/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
index a32ba30..2ae1ad1 100644
--- a/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
+++ b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
@@ -29,6 +29,7 @@ import org.apache.jena.query.ReadWrite ;
import org.apache.jena.sparql.core.DatasetGraph ;
import org.apache.jena.sparql.core.Quad ;
import org.apache.jena.sparql.sse.SSE ;
+import org.apache.jena.system.ThreadAction ;
import org.apache.jena.system.ThreadTxn ;
import org.apache.jena.system.Txn ;
import org.apache.jena.tdb.TDB ;
@@ -225,7 +226,7 @@ public class TestTransPromote {
DatasetGraphTransaction.readCommittedPromotion = b ;
DatasetGraph dsg = create() ;
// Start long running reader.
- ThreadTxn tt = ThreadTxn.threadTxnRead(dsg, () -> {
+ ThreadAction tt = ThreadTxn.threadTxnRead(dsg, () -> {
long x = Iter.count(dsg.find()) ;
if ( x != 0 )
throw new RuntimeException() ;
@@ -279,7 +280,7 @@ public class TestTransPromote {
DatasetGraphTransaction.readCommittedPromotion = allowReadCommitted ;
DatasetGraph dsg = create() ;
- ThreadTxn tt = asyncCommit?
+ ThreadAction tt = asyncCommit?
ThreadTxn.threadTxnWrite(dsg, () -> dsg.add(q3) ) :
ThreadTxn.threadTxnWriteAbort(dsg, () -> dsg.add(q3)) ;