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

has_child can cause an infinite loop (100% CPU) when used in bool query #3955

Closed
joshcanfield opened this Issue Oct 23, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@joshcanfield
Copy link

commented Oct 23, 2013

The defect is in
ChildrenQuery.ParentScorer#nextDoc()

          @Override
            public int nextDoc() throws IOException {
                if (remaining == 0) {
                    return NO_MORE_DOCS;
                }
...

This fails to update currentDocId. This causes ChildrenQuery.ParentScorer#docID() to continue returning the last doc id forever.

The BooleanScorer calls

public boolean score(Collector collector, int max, int firstDocID)

passing the firstDocID it pulled from the docID(). When the ParentScorer finishes with a low id document but continues to get processed and added to the BucketTable it opens the possibility of a document from the other boolean sub queries overlapping and causing get an infinite loop.

The fix is to set
currentDocId = NO_MORE_DOCS;
in both int nextDoc() and int advance(int target)

@s1monw

This comment has been minimized.

Copy link
Contributor

commented Oct 24, 2013

+1 to the fix! GOOD CATCH! If I recall correctly the test query utils check for this don't we pass those queries through it? @jpountz any idea?

@jpountz

This comment has been minimized.

Copy link
Contributor

commented Oct 24, 2013

@s1monw I had the same reaction, I'll try to understand why our tests didn't catch this.

@jpountz jpountz closed this in adadc72 Oct 24, 2013

@jpountz jpountz reopened this Oct 24, 2013

jpountz added a commit that referenced this issue Oct 25, 2013

@jpountz

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2013

Pushed. Thanks Josh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.