Dear all,
In a web app we are using SDB 1.3.4 with Hash layout backed by MySQL server
ver. 5.1.49. For historical reasons, we are currently using only one DB
connection (provided by commons-dbcp 1.4 BasicDataSource) that is wrapped to
the Store object which is in turn shared and synchronized. Thus I believe,
that the following code snippet initializes and uses SDB correctly (although I
am aware that this setup is definitely not optimal - if there is time in future
we would like to make a more sensible refactoring with a connection pool, etc.)
- am I right ?
private static final StoreDesc storeDesc = new
StoreDesc(LayoutType.LayoutTripleNodesHash,
DatabaseType.MySQL);
private final static Store store;
static {
JDBC.loadDriverMySQL();
try {
store = SDBFactory.connectStore(new
SDBConnection(getDataSource()),storeDesc);
if (!StoreUtils.isFormatted(store)) {
store.getTableFormatter().create();
}
} catch (SQLException ex) {
System.err.println("Exception occured when formatting a new
store: " + ex.getMessage());
throw new RuntimeException(ex);
}
}
private Model getOntModel(String modelName) {
synchronized (store) {
return SDBFactory.connectNamedModel(store, modelName);
}
}
The problem is that in a very non-deterministic manner we get
com.hp.hpl.jena.sdb.SDBException: Exception flushing
com.hp.hpl.jena.sdb.layout2.TupleLoaderBase.flush(TupleLoaderBase.java:220)
com.hp.hpl.jena.sdb.layout2.TupleLoaderBase.finish(TupleLoaderBase.java:155)
com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.commitTuples(LoaderTuplesNodes.java:283)
com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.access$100(LoaderTuplesNodes.java:31)
com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes$Commiter.run(LoaderTuplesNodes.java:318)
java.lang.Thread.run(Thread.java:662)
root cause
java.sql.BatchUpdateException: Table 'tie.NNodeQuads' doesn't exist
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2020)
com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1451)
org.apache.commons.dbcp.DelegatingPreparedStatement.executeBatch(DelegatingPreparedStatement.java:205)
com.hp.hpl.jena.sdb.layout2.TupleLoaderBase.flush(TupleLoaderBase.java:200)
com.hp.hpl.jena.sdb.layout2.TupleLoaderBase.finish(TupleLoaderBase.java:155)
com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.commitTuples(LoaderTuplesNodes.java:283)
com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes.access$100(LoaderTuplesNodes.java:31)
com.hp.hpl.jena.sdb.layout2.LoaderTuplesNodes$Commiter.run(LoaderTuplesNodes.java:318)
java.lang.Thread.run(Thread.java:662)
What I understand from the source of TupleLoaderBase, the NNodeQuads table is
only a temporary one. Thus it might be a race problem on the underlying mysql
connection within SDB ?
Do you have any idea what the problem might be ?
Cheers,
Petr Kremen
KMI, Open University
--
The Open University is incorporated by Royal Charter (RC 000391), an exempt
charity in England & Wales and a charity registered in Scotland (SC 038302).