freme-project / e-Link

Apache License 2.0
0 stars 0 forks source link

Creating templates not thread safe #36

Closed ghsnd closed 9 years ago

ghsnd commented 9 years ago

When creating templates in parallel, some java.util.ConcurrentModificationExceptions occur. Here's the beginning of the stack trace:

java.util.ConcurrentModificationException
at com.hp.hpl.jena.mem.HashCommon$BasicKeyIterator.hasNext(HashCommon.java:349)
at com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
at com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
at com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at com.hp.hpl.jena.util.iterator.Map1Iterator.hasNext(Map1Iterator.java:48)
at com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at eu.freme.eservices.elink.TemplateDAO.generateTemplateId(TemplateDAO.java:304)
at eu.freme.broker.eservices.ELink.createTemplate(ELink.java:249)

So this points to the Jena model not being thread safe; here is some documentation at the Jena website on how to avoid this.

m1ci commented 9 years ago

fixed, can you check please?

ghsnd commented 9 years ago

I get another exception now (tested with 2 and more threads):

ERROR   2015-08-27 10:32:13,896 [http-nio-8080-exec-1] eu.freme.broker.eservices.ELink  - 
java.lang.ArrayIndexOutOfBoundsException: -3
at com.hp.hpl.jena.mem.HashedTripleBunch.add(HashedTripleBunch.java:76)
at com.hp.hpl.jena.mem.NodeToTriplesMapMem.add(NodeToTriplesMapMem.java:51)
at com.hp.hpl.jena.mem.GraphTripleStoreBase.add(GraphTripleStoreBase.java:63)
at com.hp.hpl.jena.mem.GraphMem.performAdd(GraphMem.java:37)
at com.hp.hpl.jena.graph.impl.GraphBase.add(GraphBase.java:202)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:1159)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:161)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:149)
at eu.freme.eservices.elink.TemplateDAO.addTemplate(TemplateDAO.java:213)
at eu.freme.broker.eservices.ELink.createTemplate(ELink.java:288)
m1ci commented 9 years ago

had READ lock instead of WRITE lock, not it should be fixed. please check.

ghsnd commented 9 years ago

Now I get

java.util.ConcurrentModificationException
at com.hp.hpl.jena.mem.HashCommon$BasicKeyIterator.hasNext(HashCommon.java:349)
at com.hp.hpl.jena.util.iterator.NiceIterator$1.hasNext(NiceIterator.java:103)
at com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:54)
at com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at com.hp.hpl.jena.util.iterator.Map1Iterator.hasNext(Map1Iterator.java:48)
at com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at eu.freme.eservices.elink.TemplateDAO.generateTemplateId(TemplateDAO.java:327)
at eu.freme.broker.eservices.ELink.createTemplate(ELink.java:249)
m1ci commented 9 years ago

can you please check again? IMO should be fixed

ghsnd commented 9 years ago

It is fixed, thanks. Probably my maven repo was not updated. Cleared it manually, problem solved.