Hello,

We use a Jena TDB-backed dataset (release 3.1.0) accessed through a single
JVM multi-threaded application running generally on a Microsoft Windows
server.

The read and write accesses are made using transaction and read/write locks.
Here is the SPARQL update code we use:

dataset.begin(ReadWrite.WRITE);
> model.enterCriticalSection(Lock.WRITE);
> try {
>     UpdateAction.parseExecute(sparql, model);
>     if(writeMode) {
>         dataset.commit();
>     }
> } finally {
>     model.leaveCriticalSection();
>     model.close();
>     dataset.end();
> }


Note that our SPARQL query code implements also read transactions and locks.

When multiple updates are made on our TDB-backed dataset, a
java.util.ConcurrentModificationException is sometimes thrown, leaving the
dataset in an inaccessible state.
Here is the stacktrace part:


> ...
> Caused by: java.util.ConcurrentModificationException: Reader = 1, Writer =
> 1
> at
> org.apache.jena.tdb.sys.DatasetControlMRSW.policyError(DatasetControlMRSW.java:157)
> at
> org.apache.jena.tdb.sys.DatasetControlMRSW.policyError(DatasetControlMRSW.java:152)
> at
> org.apache.jena.tdb.sys.DatasetControlMRSW.checkConcurrency(DatasetControlMRSW.java:79)
> at
> org.apache.jena.tdb.sys.DatasetControlMRSW.startUpdate(DatasetControlMRSW.java:60)
> at
> org.apache.jena.tdb.store.nodetupletable.NodeTupleTableConcrete.startWrite(NodeTupleTableConcrete.java:65)
> at
> org.apache.jena.tdb.store.nodetupletable.NodeTupleTableConcrete.sync(NodeTupleTableConcrete.java:249)


How can we avoid such a situation ?
Can we safely do without read/write locks when we use transactions in a
single JVM multi-threaded application ?

Thank you in advance for your help.

Sincerely,
Laurent

Reply via email to