I reassure you, my application EulerGUI uses transactions;
anyway if one starts using them in a JVM session, TDB will grunt at any
following non-transactional I/O.

That was just an odd test.

To complete what you just wrote,
and check that I unsderstood well,

- a given TDB directoring D1 can be accessed only by one JVM,
- but by any number of threads,
- but each thread must have its own Dataset objet created with D1

What is not crystal clear to me, is the scope of a TDB transaction.
A transaction can be started at the Dataset level, or the Model level. Can
you confirm / infirm this :

-  a TDB transaction at the Dataset level involves all triples in all model
named or default,
-   a TDB transaction at the Model level does not consider what happens on
other Models, that is, each model is transactionally independant (unless
one uses the NamedModel( "urn:x-arq:UnionGraph" ) )



whatever the setting



.


2014-01-30 Andy Seaborne <[email protected]>

> On 30/01/14 14:35, Jean-Marc Vanel wrote:
>
>> So, close is discouraged, and seems no more useful.
>>
>
>
>  Then, is one of TDB.sync() useful to call, or is TDB imune to sudden power
>> off ?
>>
>
> If you use transactions, then it's immune to power off, JVM crahses or
> "kill -9".  You are not using transactions in that test case -- no
> .begin/.commit/.end
>
> http://jena.apache.org/documentation/tdb/tdb_transactions.html
>
> If you use it non-transactionally, use TDB.sync at least before exiting
> the JVM, but better every so often, but it's not proof against crashes that
> way when updates have happened but TDB.sync has not returned.  A crash
> during TDB.sync can corrupt the DB.  (It is OK for read-only use - but read
> transactions are very cheap so use them).
>
>         Andy
>
>
>
>
>>
>> 2014-01-30 Andy Seaborne <[email protected]>
>>
>>  Hi Jean-Marc,
>>>
>>> Thank you for the report - especially a link to the complete code as well
>>> as the in-email description and discussion.
>>>
>>> This is JENA-571, or rather it's reverse.  It looks like there is a bad
>>> side effect due to caching.  The closed graph is still in the
>>> DatasetGraph
>>> cache and also in the DatasetCache.
>>>
>>> I've reopened JENA-571.  I suspect that caching of graphs (and models
>>> higher up) is not nearly as import as it once was.
>>>
>>> Workaround is to not close models (or datasets).
>>>
>>> In TDB, the true state is on-disk and also in a single system wide object
>>> for the location.  This is shared, which is essential because it avoids a
>>> lot of disk I/O on opening.creating.  .close() isn't really doing
>>> anything
>>> much.
>>>
>>>          Andy
>>>
>>>
>>> On 29/01/14 12:30, Jean-Marc Vanel wrote:
>>>
>>>  Hi
>>>>
>>>> Jena 2.11.1 TBD throws ClosedException: "already closed", when 2.11.0
>>>> did
>>>> not.
>>>> The test below involves adding a triple in a named model,
>>>> closing the model,
>>>> re-opening the dataset and the same model.
>>>>
>>>> Note that closing the whole dataset instead of the model works fine.
>>>>
>>>> Here is the test (sorry , it's in Scala):
>>>>
>>>>     @Test def storeTripleinNamedDatasetandRetrieve() {
>>>>       val directory = new File("bbtest");
>>>>       directory.mkdirs();
>>>>       val dataset = TDBFactory.createDataset(
>>>> directory.getAbsolutePath());
>>>>       val modelName = "test" // "<test>"
>>>>       val model = dataset.getNamedModel(modelName);
>>>>
>>>>       val obj = "a"
>>>>       val subject = "c"
>>>>       val predicate = model.createProperty("p");
>>>>       val subjectResource = model.createResource(subject);
>>>>       val objectResource = model.createResource(obj);
>>>>       model.add(model.createStatement(subjectResource, predicate,
>>>> objectResource))
>>>>
>>>>       if (!model.isClosed()) {
>>>>         model.close(); // com.hp.hpl.jena.shared.ClosedException:
>>>> already
>>>> closed
>>>>         //        dataset.close(); // OK!
>>>>         System.out.println("Test TDB: model closed:\t" + dataset)
>>>>       }
>>>>
>>>>       {
>>>>         val dataset = TDBFactory.createDataset(
>>>> directory.getAbsolutePath());
>>>>         val model = dataset.getNamedModel(modelName);
>>>>         System.out.println("Test TDB: model reopened:\t" + dataset)
>>>>
>>>>         println(
>>>>           "model.size() " +
>>>>             model.size())
>>>>         val sIter = model.listStatements()
>>>>         for (st <- sIter) {
>>>>           println(st)
>>>>         }
>>>>         assertTrue("model.size == 1", model.size == 1);
>>>>       }
>>>>
>>>>
>>>> Complete code:
>>>> http://svn.code.sf.net/p/eulergui/code/trunk/eulergui/
>>>> src/test/scala/eulergui/jena/JenaTDBTest.scala
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>


-- 
Jean-Marc Vanel
Déductions SARL - Consulting, services, training,
Rule-based programming, Semantic Web
http://deductions-software.com/
+33 (0)6 89 16 29 52
Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui

Reply via email to