You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Laura Morales <la...@mail.com> on 2018/11/13 08:44:28 UTC

update INSERT on TDB2 results in org.apache.jena.dboe.transaction.txn.TransactionException: Not in a transaction

assembler.ttl
=============
PREFIX : <http://example.org/>
PREFIX ja: <http://jena.hpl.hp.com/2005/11/Assembler#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX tdb: <http://jena.hpl.hp.com/2008/tdb#>
PREFIX tdb2: <http://jena.apache.org/2016/tdb#>
PREFIX text: <http://jena.apache.org/text#>

:dataset a ja:RDFDataset ;
    ja:namedGraph [ ja:graphName :g1 ;
                    ja:graph :graph1 ] ;
    ja:namedGraph [ ja:graphName :g2 ;
                    ja:graph :graph2 ] ;
    .

:graph1 a tdb2:GraphTDB2 ;
    tdb2:location "g1" .

:graph2 a tdb2:GraphTDB2 ;
    tdb2:location "g2" .

query.rq
========
PREFIX : <http://example.org/>

INSERT
{
    GRAPH :g2 {
        ?s ?p ?o
    }
}
WHERE {
    GRAPH :g1 {
        ?s ?p ?o
    }
}

commands
========

$ sparql --desc assembler.ttl "ask {}"
Ask => Yes

$ update --desc assembler.ttl --update query.rq
org.apache.jena.dboe.transaction.txn.TransactionException: Not in a transaction
	at org.apache.jena.dboe.transaction.txn.TransactionalComponentLifecycle.checkTxn(TransactionalComponentLifecycle.java:417)
	at org.apache.jena.dboe.trans.bplustree.BPlusTree.getRootRead(BPlusTree.java:159)
	at org.apache.jena.dboe.trans.bplustree.BPlusTree.iterator(BPlusTree.java:348)
	at org.apache.jena.tdb2.store.tupletable.TupleIndexRecord.all(TupleIndexRecord.java:251)
	at org.apache.jena.tdb2.store.tupletable.TupleTable.find(TupleTable.java:148)
	at org.apache.jena.tdb2.store.nodetupletable.NodeTupleTableConcrete.find(NodeTupleTableConcrete.java:161)
	at org.apache.jena.tdb2.solver.StageMatchTuple.makeNextStage(StageMatchTuple.java:96)
	at org.apache.jena.tdb2.solver.StageMatchTuple.makeNextStage(StageMatchTuple.java:37)
	at org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(RepeatApplyIterator.java:48)
	at org.apache.jena.tdb2.solver.SolverLib$IterAbortable.hasNext(SolverLib.java:192)
	at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
	at org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper.hasNextBinding(QueryIterPlainWrapper.java:53)
	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
	at org.apache.jena.sparql.engine.main.iterator.QueryIterGraph$QueryIterGraphInner.hasNextBinding(QueryIterGraph.java:121)
	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
	at org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:74)
	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
	at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
	at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
	at java.util.Iterator.forEachRemaining(Iterator.java:115)
	at org.apache.jena.atlas.data.DataBag.addAll(DataBag.java:94)
	at org.apache.jena.sparql.modify.UpdateEngineWorker.visit(UpdateEngineWorker.java:410)
	at org.apache.jena.sparql.modify.request.UpdateModify.visit(UpdateModify.java:100)
	at org.apache.jena.sparql.modify.UpdateVisitorSink.send(UpdateVisitorSink.java:46)
	at org.apache.jena.sparql.modify.UpdateVisitorSink.send(UpdateVisitorSink.java:26)
	at org.apache.jena.atlas.iterator.Iter.sendToSink(Iter.java:562)
	at org.apache.jena.atlas.iterator.Iter.sendToSink(Iter.java:569)
	at org.apache.jena.sparql.modify.UpdateProcessorBase.execute(UpdateProcessorBase.java:59)
	at arq.update.execOneFile(update.java:105)
	at arq.update.execUpdate(update.java:81)
	at arq.cmdline.CmdUpdate.exec(CmdUpdate.java:63)
	at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
	at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
	at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
	at arq.update.main(update.java:49)


What/Who is causing this problem? Am I using the wrong command-line tool? And is there a way that I can fix this?
Note: if I use Fuseki everything seems to work fine. That is, if I use the same dataset definition in the fuseki assembler file, and if I issue the same update query from the fuseki web UI. But if I use the "update" command line tool instead, I get a transaction error. I'm not sure what fuseki is doing differently...

Re: update INSERT on TDB2 results in org.apache.jena.dboe.transaction.txn.TransactionException: Not in a transaction

Posted by Laura Morales <la...@mail.com>.
Thank you Rob. The reason I tried "update" is because the query is over a RDFDataset, not a DatasetTDB (I guess tdb2.* don't work on RDFDataset?).
Is there another tool that I can use for handling transactional queries on a RDFDataset from the command line? Otherwise I guess I'll open a feature request ticket for "update".

 
 

Sent: Tuesday, November 13, 2018 at 11:14 AM
From: "Rob Vesse" <rv...@dotnetrdf.org>
To: users@jena.apache.org
Subject: Re: update INSERT on TDB2 results in org.apache.jena.dboe.transaction.txn.TransactionException: Not in a transaction
Fuseki is properly managing transactions for the underlying datasets

update is a general purpose command that doesn't have awareness of transactions (though it probably could/should)

Use tdb2.tdbupdate to run updates on TDB2, note that in the command line tools there are a variety of tools named tdb2.<tool> which should be used for interacting with TDB 2 databases in preference to the general purpose commands.

Rob

On 13/11/2018, 08:45, "Laura Morales" <la...@mail.com> wrote:

assembler.ttl
=============
PREFIX : <http://example.org/>
PREFIX ja: <http://jena.hpl.hp.com/2005/11/Assembler#[http://jena.hpl.hp.com/2005/11/Assembler#]>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#[http://www.w3.org/1999/02/22-rdf-syntax-ns#]>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#[http://www.w3.org/2000/01/rdf-schema#]>
PREFIX tdb: <http://jena.hpl.hp.com/2008/tdb#[http://jena.hpl.hp.com/2008/tdb#]>
PREFIX tdb2: <http://jena.apache.org/2016/tdb#[http://jena.apache.org/2016/tdb#]>
PREFIX text: <http://jena.apache.org/text#[http://jena.apache.org/text#]>

:dataset a ja:RDFDataset ;
ja:namedGraph [ ja:graphName :g1 ;
ja:graph :graph1 ] ;
ja:namedGraph [ ja:graphName :g2 ;
ja:graph :graph2 ] ;
.

:graph1 a tdb2:GraphTDB2 ;
tdb2:location "g1" .

:graph2 a tdb2:GraphTDB2 ;
tdb2:location "g2" .

query.rq
========
PREFIX : <http://example.org/[http://example.org/]>

INSERT
{
GRAPH :g2 {
?s ?p ?o
}
}
WHERE {
GRAPH :g1 {
?s ?p ?o
}
}

commands
========

$ sparql --desc assembler.ttl "ask {}"
Ask => Yes

$ update --desc assembler.ttl --update query.rq
org.apache.jena.dboe.transaction.txn.TransactionException: Not in a transaction
at org.apache.jena.dboe.transaction.txn.TransactionalComponentLifecycle.checkTxn(TransactionalComponentLifecycle.java:417)
at org.apache.jena.dboe.trans.bplustree.BPlusTree.getRootRead(BPlusTree.java:159)
at org.apache.jena.dboe.trans.bplustree.BPlusTree.iterator(BPlusTree.java:348)
at org.apache.jena.tdb2.store.tupletable.TupleIndexRecord.all(TupleIndexRecord.java:251)
at org.apache.jena.tdb2.store.tupletable.TupleTable.find(TupleTable.java:148)
at org.apache.jena.tdb2.store.nodetupletable.NodeTupleTableConcrete.find(NodeTupleTableConcrete.java:161)
at org.apache.jena.tdb2.solver.StageMatchTuple.makeNextStage(StageMatchTuple.java:96)
at org.apache.jena.tdb2.solver.StageMatchTuple.makeNextStage(StageMatchTuple.java:37)
at org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(RepeatApplyIterator.java:48)
at org.apache.jena.tdb2.solver.SolverLib$IterAbortable.hasNext(SolverLib.java:192)
at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
at org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper.hasNextBinding(QueryIterPlainWrapper.java:53)
at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
at org.apache.jena.sparql.engine.main.iterator.QueryIterGraph$QueryIterGraphInner.hasNextBinding(QueryIterGraph.java:121)
at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
at org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:74)
at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
at java.util.Iterator.forEachRemaining(Iterator.java:115)
at org.apache.jena.atlas.data.DataBag.addAll(DataBag.java:94)
at org.apache.jena.sparql.modify.UpdateEngineWorker.visit(UpdateEngineWorker.java:410)
at org.apache.jena.sparql.modify.request.UpdateModify.visit(UpdateModify.java:100)
at org.apache.jena.sparql.modify.UpdateVisitorSink.send(UpdateVisitorSink.java:46)
at org.apache.jena.sparql.modify.UpdateVisitorSink.send(UpdateVisitorSink.java:26)
at org.apache.jena.atlas.iterator.Iter.sendToSink(Iter.java:562)
at org.apache.jena.atlas.iterator.Iter.sendToSink(Iter.java:569)
at org.apache.jena.sparql.modify.UpdateProcessorBase.execute(UpdateProcessorBase.java:59)
at arq.update.execOneFile(update.java:105)
at arq.update.execUpdate(update.java:81)
at arq.cmdline.CmdUpdate.exec(CmdUpdate.java:63)
at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
at arq.update.main(update.java:49)


What/Who is causing this problem? Am I using the wrong command-line tool? And is there a way that I can fix this?
Note: if I use Fuseki everything seems to work fine. That is, if I use the same dataset definition in the fuseki assembler file, and if I issue the same update query from the fuseki web UI. But if I use the "update" command line tool instead, I get a transaction error. I'm not sure what fuseki is doing differently...




 

Re: update INSERT on TDB2 results in org.apache.jena.dboe.transaction.txn.TransactionException: Not in a transaction

Posted by Rob Vesse <rv...@dotnetrdf.org>.
Fuseki is properly managing transactions for the underlying datasets

update is a general purpose command that doesn't have awareness of transactions (though it probably could/should)

Use tdb2.tdbupdate to run updates on TDB2, note that in the command line tools there are a variety of tools named tdb2.<tool> which should be used for interacting with TDB 2 databases in preference to the general purpose commands.

Rob

On 13/11/2018, 08:45, "Laura Morales" <la...@mail.com> wrote:

    assembler.ttl
    =============
    PREFIX : <http://example.org/>
    PREFIX ja: <http://jena.hpl.hp.com/2005/11/Assembler#>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX tdb: <http://jena.hpl.hp.com/2008/tdb#>
    PREFIX tdb2: <http://jena.apache.org/2016/tdb#>
    PREFIX text: <http://jena.apache.org/text#>
    
    :dataset a ja:RDFDataset ;
        ja:namedGraph [ ja:graphName :g1 ;
                        ja:graph :graph1 ] ;
        ja:namedGraph [ ja:graphName :g2 ;
                        ja:graph :graph2 ] ;
        .
    
    :graph1 a tdb2:GraphTDB2 ;
        tdb2:location "g1" .
    
    :graph2 a tdb2:GraphTDB2 ;
        tdb2:location "g2" .
    
    query.rq
    ========
    PREFIX : <http://example.org/>
    
    INSERT
    {
        GRAPH :g2 {
            ?s ?p ?o
        }
    }
    WHERE {
        GRAPH :g1 {
            ?s ?p ?o
        }
    }
    
    commands
    ========
    
    $ sparql --desc assembler.ttl "ask {}"
    Ask => Yes
    
    $ update --desc assembler.ttl --update query.rq
    org.apache.jena.dboe.transaction.txn.TransactionException: Not in a transaction
    	at org.apache.jena.dboe.transaction.txn.TransactionalComponentLifecycle.checkTxn(TransactionalComponentLifecycle.java:417)
    	at org.apache.jena.dboe.trans.bplustree.BPlusTree.getRootRead(BPlusTree.java:159)
    	at org.apache.jena.dboe.trans.bplustree.BPlusTree.iterator(BPlusTree.java:348)
    	at org.apache.jena.tdb2.store.tupletable.TupleIndexRecord.all(TupleIndexRecord.java:251)
    	at org.apache.jena.tdb2.store.tupletable.TupleTable.find(TupleTable.java:148)
    	at org.apache.jena.tdb2.store.nodetupletable.NodeTupleTableConcrete.find(NodeTupleTableConcrete.java:161)
    	at org.apache.jena.tdb2.solver.StageMatchTuple.makeNextStage(StageMatchTuple.java:96)
    	at org.apache.jena.tdb2.solver.StageMatchTuple.makeNextStage(StageMatchTuple.java:37)
    	at org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(RepeatApplyIterator.java:48)
    	at org.apache.jena.tdb2.solver.SolverLib$IterAbortable.hasNext(SolverLib.java:192)
    	at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
    	at org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper.hasNextBinding(QueryIterPlainWrapper.java:53)
    	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    	at org.apache.jena.sparql.engine.main.iterator.QueryIterGraph$QueryIterGraphInner.hasNextBinding(QueryIterGraph.java:121)
    	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    	at org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:74)
    	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    	at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
    	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    	at org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:39)
    	at org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:114)
    	at java.util.Iterator.forEachRemaining(Iterator.java:115)
    	at org.apache.jena.atlas.data.DataBag.addAll(DataBag.java:94)
    	at org.apache.jena.sparql.modify.UpdateEngineWorker.visit(UpdateEngineWorker.java:410)
    	at org.apache.jena.sparql.modify.request.UpdateModify.visit(UpdateModify.java:100)
    	at org.apache.jena.sparql.modify.UpdateVisitorSink.send(UpdateVisitorSink.java:46)
    	at org.apache.jena.sparql.modify.UpdateVisitorSink.send(UpdateVisitorSink.java:26)
    	at org.apache.jena.atlas.iterator.Iter.sendToSink(Iter.java:562)
    	at org.apache.jena.atlas.iterator.Iter.sendToSink(Iter.java:569)
    	at org.apache.jena.sparql.modify.UpdateProcessorBase.execute(UpdateProcessorBase.java:59)
    	at arq.update.execOneFile(update.java:105)
    	at arq.update.execUpdate(update.java:81)
    	at arq.cmdline.CmdUpdate.exec(CmdUpdate.java:63)
    	at jena.cmd.CmdMain.mainMethod(CmdMain.java:93)
    	at jena.cmd.CmdMain.mainRun(CmdMain.java:58)
    	at jena.cmd.CmdMain.mainRun(CmdMain.java:45)
    	at arq.update.main(update.java:49)
    
    
    What/Who is causing this problem? Am I using the wrong command-line tool? And is there a way that I can fix this?
    Note: if I use Fuseki everything seems to work fine. That is, if I use the same dataset definition in the fuseki assembler file, and if I issue the same update query from the fuseki web UI. But if I use the "update" command line tool instead, I get a transaction error. I'm not sure what fuseki is doing differently...