Notice that Andy specifically said in his response:

  call this very early (before any TDB related activity)

Rob

On 28/02/2018, 16:21, "Chris Wood" <c.c.w...@gmail.com> wrote:

    Hi Rob - sorry, that was an over-simplification of the psedocode; I do call
    
        dataset.begin(ReadWrite.WRITE);
    
    after initialising it.
    
    I had also wondered if setFileMode makes any difference - I was using it
    because of this Andy's comment here:
    
http://users.jena.apache.narkive.com/zUPFzLcm/tdb-shutdown-does-not-release-the-files
    
    Chris
    
    On 28 February 2018 at 14:54, Rob Vesse <rve...@dotnetrdf.org> wrote:
    
    > Two things look odd:
    >
    > - You never call dataset.begin() to start the transaction yet you later
    > try to commit() it
    > - Calling SystemTDB.setFileMode() after opening a dataset probably doesn't
    > have any effect on already open datasets though I could be wrong on this
    > point
    >
    > Rob
    >
    > On 28/02/2018, 13:08, "Chris Wood" <c.c.w...@gmail.com> wrote:
    >
    >     Hi Andy,
    >
    >     It's probably a bit more complicated than I originally suggested.
    > Inside my
    >     try statement I do a bit of processing in a separate class (I create a
    > new
    >     in-memory Dataset, and return the model from it, so I can add it to my
    > my
    >     main dataset); but I also use this class to initialise the default
    > model. I
    >     wonder if this is confusing the transaction...
    >
    >     With a bit of pseudocode:
    >
    >         Dataset dataset = TDBFactory.createDataset("path/to/tdb");
    >         Model model = new Processing(dataset).;
    >         SystemTDB.setFileMode(FileMode.direct);
    >
    >         try {
    >            Model m = model.dataStructure();
    >            model.add(m);
    >            dataset.commit();
    >         } finally {
    >            dataset.close();
    >         }
    >
    >       Processing.java:
    >
    >         main:
    >           public Processing(Dataset dataset) {
    >     super(dataset.getDefaultModel().getGraph());
    >           }
    >
    >         dataStructure():
    >           Dataset d1 = TDBFactory.createDataset();
    >           Model m1 = d1.getDefaultModel();
    >
    >           // add stuff to m1 from an independent datasource
    >
    >           return m1;
    >
    >
    >     On 28 February 2018 at 11:30, Andy Seaborne <a...@apache.org> wrote:
    >
    >     > Chris,
    >     >
    >     > Is the dataset TDB (from TDBFactory) or a dataset holding a model,
    > maybe
    >     > with added inference, where the base graph is backed by TDB?
    >     >
    >     > It is better to put changes to the dataset inside a transaction.
    > Failing
    >     > that, it should be sync'ed  -- TDB.sync().
    >     >
    >     >     Andy
    >     >
    >     > http://jena.staging.apache.org/documentation/txn/
    >     >
    >     > On 27/02/18 18:33, Chris Wood wrote:
    >     >
    >     >> I've got a small application that follows the standard recommended
    >     >> pattern:
    >     >>
    >     >>      // initialise dataset / model
    >     >>      ...
    >     >>      try {
    >     >>          // ... add statements
    >     >>          StmtIterator r = this.my_model.listStatements();
    >     >> System.out.println(r.toList().size());
    >     >> this.dataset.commit();
    >     >>      } catch (SQLException e) {
    >     >>          e.printStackTrace();
    >     >>      } finally {
    >     >> this.dataset.close();
    >     >>      }
    >     >>
    >     >> I was running this with Jena 3.0.1, and all was fine. I've just
    > upgraded
    >     >> to
    >     >> 3.6.0. When I run the code and then check the tdb that is generated
    > with
    >     >> (on Windows):
    >     >>
    >     >>       tdbquery --loc="database" "SELECT (count(*) as ?t) where {?a
    > ?b ?c
    >     >> . }"
    >     >>
    >     >> I get a NullPointerException:
    >     >>
    >     >> Exception
    >     >> java.lang.NullPointerException
    >     >>          at
    >     >> org.apache.jena.tdb.transaction.JournalControl.replay(
    >     >> JournalControl.java:280)
    >     >>          at
    >     >> org.apache.jena.tdb.transaction.JournalControl.recoverSegmen
    >     >> t(JournalControl.java:185)
    >     >>          at
    >     >> org.apache.jena.tdb.transaction.JournalControl.recoverFromJo
    >     >> urnal(JournalControl.java:137)
    >     >>          at
    >     >> org.apache.jena.tdb.StoreConnection.forceRecoverFromJournal(
    >     >> StoreConnection.java:150)
    >     >>          at
    >     >> org.apache.jena.tdb.StoreConnection._makeAndCache(StoreConne
    >     >> ction.java:255)
    >     >>          at
    >     >> org.apache.jena.tdb.StoreConnection.make(StoreConnection.java:214)
    >     >>          at
    >     >> org.apache.jena.tdb.StoreConnection.make(StoreConnection.java:220)
    >     >>          at
    >     >> org.apache.jena.tdb.transaction.DatasetGraphTransaction.<
    >     >> init>(DatasetGraphTransaction.java:70)
    >     >>          at org.apache.jena.tdb.sys.TDBMaker._create(TDBMaker.
    > java:55)
    >     >>          at
    >     >> org.apache.jena.tdb.sys.TDBMaker.createDatasetGraphTransacti
    >     >> on(TDBMaker.java:42)
    >     >>          at
    >     >> org.apache.jena.tdb.TDBFactory._createDatasetGraph(TDBFactory.
    > java:89)
    >     >>          at
    >     >> org.apache.jena.tdb.TDBFactory.createDatasetGraph(
    > TDBFactory.java:71)
    >     >>          at org.apache.jena.tdb.TDBFactory.createDataset(
    > TDBFactory.
    >     >> java:55)
    >     >>          at tdb.cmdline.ModTDBDataset.createDataset(ModTDBDataset.
    > java:
    >     >> 103)
    >     >>          at arq.cmdline.ModDataset.getDataset(ModDataset.java:36)
    >     >>          at arq.query.getDataset(query.java:176)
    >     >>          at arq.query.queryExec(query.java:213)
    >     >>          at arq.query.exec(query.java:153)
    >     >>          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 tdb.tdbquery.main(tdbquery.java:33)
    >     >>
    >     >> What seems really weird is that if I run the code *again* (without
    >     >> deleting
    >     >> the dataset directory) the triplestore is populated.
    >     >>
    >     >>   - If I run the code ensuring I use v3.0.1, this doesn't happen,
    > and the
    >     >> tdbquery command works on the first attempt.
    >     >>   - The print statement showing the number of statements in the
    > dataset
    >     >> shows the correct number in all cases.
    >     >>
    >     >> What has changed between 3.0.1 and 3.6.0 to cause this (and any
    > hints on
    >     >> what I need to do to resolve it would be greatly appreciated!)
    >     >>
    >     >> Thanks
    >     >> Chris
    >     >>
    >     >>
    >
    >
    >
    >
    >
    >
    




Reply via email to