SOLR-18125 Make LukeRequestHandler::getFirstLiveDoc get the first live doc#4157
Open
kotman12 wants to merge 3 commits intoapache:mainfrom
Open
SOLR-18125 Make LukeRequestHandler::getFirstLiveDoc get the first live doc#4157kotman12 wants to merge 3 commits intoapache:mainfrom
kotman12 wants to merge 3 commits intoapache:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
LukeRequestHandler::getFirstLiveDoc is completely broken.
Funny little expedition as I was testing a patch I had to support distrib=true for LukeRequestHandler. It turns out the logic to fetch the first live doc from the index for a particular field (used to populate the index flags for that field) is broken in two surprising ways. As far as I can tell it's been broken since 2012. The net effect is you'll just randomly not get index flags for fields as I show in the test.
Timeline:
docsEnum = reader.termDocsEnum(liveDocs, field, termText, offset)apparently would return null, perhaps when there were no live docs for this particular term. There used to be a guard in the loop condition which ensured that it would exit on the first non-nulldocsEnumit encountered across all terms. Not entirely sure why exactly this extra condition was necessary; it would only matter if the first non-null docsEnum also didn't have any docs. Either away, reaching such a state apparently warranted ending the search altogether. LUCENE-4355 changed the semantics totermsEnum.docs(liveDocs, docsEnum, offset)which could not return null, as much is obvious from the fact that the inner null check disappeared. However, the earlierdocsEnum == nullremained in the loop condition, almost certainly by mistake.Solution
Fix the bug and git rid of a vestigial check. Diffs of how we got here mentioned in JIRA.
Tests
Quite easily show that you get no index flags when you should get index flags.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.