Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lucene wrapped in SailRepository with multithreading gives error #192

Closed
jgrzebyta opened this issue Jun 23, 2016 · 8 comments
Closed

Lucene wrapped in SailRepository with multithreading gives error #192

jgrzebyta opened this issue Jun 23, 2016 · 8 comments
Labels
🐞 bug issue is a bug

Comments

@jgrzebyta
Copy link
Contributor

Affected: v 2.0-SNAPSHOT,
Java: openjdk-8
os: Ubuntu 16.04

I use LuceneSailRepository wrapped in SailsRepository. MemoryStore with dump file is used as a storage.

I load data in multithreads managed by Executors.newFixedThreadPoolpool. When I do .invokeAll
I got error about closed call when new request is done. It seems Lucene index in not thread safety.

The full stacktrace is:

23:29:47,677 [pool-3-thread-2] ERROR LuceneSailConnection: Rolling back org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/tmp/rdf4j-loader-s5A6SCKMe.34724407296800170144873/lucenedir/write.lock
    at org.apache.lucene.store.Lock.obtain(Lock.java:89)
    at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:780)
    at org.eclipse.rdf4j.sail.lucene.LuceneIndex.getIndexWriter(LuceneIndex.java:291)
    at org.eclipse.rdf4j.sail.lucene.LuceneIndex.invalidateReaders(LuceneIndex.java:581)
    at org.eclipse.rdf4j.sail.lucene.LuceneIndex.commit(LuceneIndex.java:651)
    at org.eclipse.rdf4j.sail.lucene.LuceneSailConnection.addRemoveStatements(LuceneSailConnection.java:252)
    at org.eclipse.rdf4j.sail.lucene.LuceneSailConnection.commit(LuceneSailConnection.java:217)
    at org.eclipse.rdf4j.repository.sail.SailRepositoryConnection.commit(SailRepositoryConnection.java:169)
    at triple.loader$eval939$fn__940$fn__941.invoke(loader.clj:122)
    at triple.loader$eval939$fn__940.invoke(loader.clj:98)
    at clojure.lang.MultiFn.invoke(MultiFn.java:238)
    at triple.loader$eval935$fn__936.invoke(loader.clj:88)
    at clojure.lang.MultiFn.invoke(MultiFn.java:238)
    at sparql$load_multidata$fn__1094$fn__1095.invoke(sparql.clj:102)
    at clojure.lang.AFn.call(AFn.java:18)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

23:29:48,694 [pool-3-thread-2] ERROR LuceneSailConnection: Committing operations in lucenesail, encountered exception org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/tmp/rdf4j-loader-s5A6SCKMe.34724407296800170144873/lucenedir/write.lock. Only some operations were stored, 1 operations are discarded. Lucene Index is now corrupt. org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/tmp/rdf4j-loader-s5A6SCKMe.34724407296800170144873/lucenedir/write.lock
    at org.apache.lucene.store.Lock.obtain(Lock.java:89)
    at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:780)
    at org.eclipse.rdf4j.sail.lucene.LuceneIndex.getIndexWriter(LuceneIndex.java:291)
    at org.eclipse.rdf4j.sail.lucene.LuceneIndex.rollback(LuceneIndex.java:658)
    at org.eclipse.rdf4j.sail.lucene.LuceneSailConnection.addRemoveStatements(LuceneSailConnection.java:256)
    at org.eclipse.rdf4j.sail.lucene.LuceneSailConnection.commit(LuceneSailConnection.java:217)
    at org.eclipse.rdf4j.repository.sail.SailRepositoryConnection.commit(SailRepositoryConnection.java:169)
    at triple.loader$eval939$fn__940$fn__941.invoke(loader.clj:122)
    at triple.loader$eval939$fn__940.invoke(loader.clj:98)
    at clojure.lang.MultiFn.invoke(MultiFn.java:238)
    at triple.loader$eval935$fn__936.invoke(loader.clj:88)
    at clojure.lang.MultiFn.invoke(MultiFn.java:238)
    at sparql$load_multidata$fn__1094$fn__1095.invoke(sparql.clj:102)
    at clojure.lang.AFn.call(AFn.java:18)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

23:29:48,709 [clojure-agent-send-off-pool-0] ERROR sparql: There is error:  java.util.concurrent.ExecutionException
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: cannot close: prepareCommit was already called with no corresponding call to commit
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:313)
    at sparql$load_multidata.invokeStatic(sparql.clj:110)
    at sparql$load_multidata.invoke(sparql.clj:90)
    at triple.multiload$fn__1114.invokeStatic(multiload.clj:15)
    at triple.multiload$fn__1114.invoke(multiload.clj:13)
    at clojure.test$test_var$fn__7983.invoke(test.clj:716)
    at clojure.test$test_var.invokeStatic(test.clj:716)
    at clojure.test$test_var.invoke(test.clj:707)
    at boot.user$eval133$fn__134.doInvoke(boot.user3412006909439801406.clj:23)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$apply.invoke(core.clj:641)
    at boot.core$construct_tasks.doInvoke(core.clj:911)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$apply.invoke(core.clj:641)
    at boot.core$boot$fn__933.invoke(core.clj:949)
    at clojure.core$binding_conveyor_fn$fn__4676.invoke(core.clj:1938)
    at clojure.lang.AFn.call(AFn.java:18)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: cannot close: prepareCommit was already called with no corresponding call to commit
    at org.apache.lucene.index.IndexWriter.shutdown(IndexWriter.java:960)
    at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1015)
    at org.eclipse.rdf4j.sail.lucene.LuceneIndex.shutDown(LuceneIndex.java:322)
    at org.eclipse.rdf4j.sail.lucene.LuceneSail.shutDown(LuceneSail.java:291)
    at org.eclipse.rdf4j.repository.sail.SailRepository.shutDownInternal(SailRepository.java:169)
    at org.eclipse.rdf4j.repository.base.AbstractRepository.shutDown(AbstractRepository.java:45)
    at triple.loader$eval939$fn__940.invoke(loader.clj:98)
    at clojure.lang.MultiFn.invoke(MultiFn.java:238)
    at triple.loader$eval935$fn__936.invoke(loader.clj:88)
    at clojure.lang.MultiFn.invoke(MultiFn.java:238)
    at sparql$load_multidata$fn__1094$fn__1095.invoke(sparql.clj:102)
    ... 5 more
@pulquero
Copy link

Just to confirm you are using a connection per thread?

@abrokenjester abrokenjester added the 🐞 bug issue is a bug label Jun 27, 2016
@jgrzebyta
Copy link
Contributor Author

On 24 Jun 2016 9:45 p.m., "pulquero" notifications@github.com wrote:

Just to confirm you are using a connection per thread?

Yes. Also I am opening an isolated transaction (read only or this kind) but
it seems it does not affect. Maybe the issue is I use memory storage but
the error is within the Lucent part.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@pulquero
Copy link

Question for someone in the know but why is every class in rdf4j-sail-lucene marked as deprecated?

@abrokenjester
Copy link
Contributor

It looks as if these classes were for an older Lucene version that we got rid of. The idea when transitioning to RDF4J was to remove support for Lucene 3 and 4, and only keep supporting the latest Lucene 5 (alongside solr and elasticsearch of course).

However due to the fact that the transition took so long and I had to do several large sync operations to keep the new github repo up to date with developments on the bitbucket side, something may have gone wonky. @pulquero could you doublecheck if we actually have the correct version of the lucene sail code included in the GitHub repo? If not, we should probably re-insert that part of the code from Bitbucket.

@pulquero
Copy link

It looks to be the correct one, which is this one https://bitbucket.org/openrdf/sesame/src/69dcca77110d/core/sail/fts/lucene/?at=master but the classes are deprecated here.

@abrokenjester
Copy link
Contributor

They might simply be the result of a bad merge. If it's the correct code we
can just remove the deprecated notices again.

sent from my phone
On 1/07/2016 4:38 am, "pulquero" notifications@github.com wrote:

It looks to be the correct one, which is this one
https://bitbucket.org/openrdf/sesame/src/69dcca77110d/core/sail/fts/lucene/?at=master
but the classes are deprecated here.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#192 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAseyPE_T93TCiNuGJXkaTS5KgvdmRcmks5qQ_EZgaJpZM4I9UAt
.

@pulquero
Copy link

@jgrzebyta PR with fix now available. Please take a look and confirm if you believe the newly added test covers your use case.

@jgrzebyta
Copy link
Contributor Author

jgrzebyta commented Jul 4, 2016

@pulquero IMO The test code covers my case. Unfortunately I do not have the original code so I cannot check the solution - I went into single thread solution.

Ps. I am not sure if your pull request was added to the main project if so please could you close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug
Projects
None yet
Development

No branches or pull requests

3 participants