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

Potential race condition, calls on MemoryIndex before freeze #63

Closed
dyshi opened this issue Oct 2, 2015 · 4 comments
Closed

Potential race condition, calls on MemoryIndex before freeze #63

dyshi opened this issue Oct 2, 2015 · 4 comments

Comments

@dyshi
Copy link

dyshi commented Oct 2, 2015

Observed this error, running using IntelliJ on a Windows 7 machine
java.lang.RuntimeException: Interrupted during match
at uk.co.flax.luwak.matchers.ParallelMatcher.finish(ParallelMatcher.java:114)
at uk.co.flax.luwak.Monitor.match(Monitor.java:476)
at uk.co.flax.luwak.Monitor.match(Monitor.java:457)
at uk.co.flax.luwak.matchers.ConcurrentMatcherTestBase.testMatchesAreDisambiguated(ConcurrentMatcherTestBase.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:168)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.util.concurrent.ExecutionException: java.lang.AssertionError
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at uk.co.flax.luwak.matchers.ParallelMatcher.finish(ParallelMatcher.java:103)
... 39 more
Caused by: java.lang.AssertionError
at org.apache.lucene.util.BytesRefHash.compact(BytesRefHash.java:148)
at org.apache.lucene.util.BytesRefHash.sort(BytesRefHash.java:164)
at org.apache.lucene.index.memory.MemoryIndex$Info.sortTerms(MemoryIndex.java:723)
at org.apache.lucene.index.memory.MemoryIndex$MemoryIndexReader$MemoryTermsEnum.(MemoryIndex.java:906)
at org.apache.lucene.index.memory.MemoryIndex$MemoryIndexReader$MemoryFields$1.iterator(MemoryIndex.java:842)
at org.apache.lucene.index.TermContext.build(TermContext.java:93)
at org.apache.lucene.search.TermQuery.createWeight(TermQuery.java:192)
at org.apache.lucene.search.IndexSearcher.createWeight(IndexSearcher.java:855)
at org.apache.lucene.search.IndexSearcher.createNormalizedWeight(IndexSearcher.java:838)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:486)
at uk.co.flax.luwak.matchers.CollectingMatcher.doMatchQuery(CollectingMatcher.java:55)
at uk.co.flax.luwak.CandidateMatcher.matchQuery(CandidateMatcher.java:63)
at uk.co.flax.luwak.matchers.ParallelMatcher$MatcherWorker.call(ParallelMatcher.java:134)
at uk.co.flax.luwak.matchers.ParallelMatcher$MatcherWorker.call(ParallelMatcher.java:119)
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)

@romseygeek
Copy link
Collaborator

Hmm, I can't see how this could actually happen by inspecting the code. MemoryIndex.freeze() gets called in InputDocument.finish(), which is called by Builder.build(). Are you running this using a modified version of lucene? Or are you creating InputDocuments directly instead of using the Builder?

@romseygeek
Copy link
Collaborator

Actually, I think this is caused by #58 - master branch passes all the time before I merged that in, and fails all the time now. Am investigating.

@romseygeek
Copy link
Collaborator

Yes, #58 inadvertently removed the MemoryIndex.freeze() call. Have fixed.

romseygeek added a commit that referenced this issue Oct 5, 2015
Think this was lost in a bad merge somewhere, but we need to ensure that
MemoryIndex is made immutable before being used in an InputDocument, otherwise
bad things happen during concurrent matching.

Fixes #63
@dcollins53
Copy link
Contributor

Oops, #58 was me, bad merge sorry.

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

No branches or pull requests

3 participants