Throw an ISE rather than an hard assertion in SearchPhaseController#getTotalHits

This change turns an assertion into an IllegalStateException in SearchPhaseController#getTotalHits.
The goal is to help identify the cause of the failures in https://github.com/elastic/elasticsearch/issues/37179
which seems to fail only in CI.
The assertion will be restored when the issue is solved (NORELEASE).
This commit is contained in:
Jim Ferenczi 2019-01-09 13:35:41 +01:00
parent dc371ef593
commit 84d520b0e5
1 changed files with 7 additions and 1 deletions

View File

@ -760,7 +760,13 @@ public final class SearchPhaseController {
if (trackTotalHitsUpTo == SearchContext.TRACK_TOTAL_HITS_DISABLED) {
return null;
} else if (trackTotalHitsUpTo == SearchContext.TRACK_TOTAL_HITS_ACCURATE) {
assert totalHitsRelation == Relation.EQUAL_TO;
// NORELEASE The assertion below has been replaced by a runtime exception in order to debug
// https://github.com/elastic/elasticsearch/issues/37179.
// The assertion should be restored and the exception removed when this issue is solved.
// assert totalHitsRelation == Relation.EQUAL_TO;
if (totalHitsRelation != Relation.EQUAL_TO) {
throw new IllegalStateException("Expected accurate total hits but got " + new TotalHits(totalHits, totalHitsRelation));
}
return new TotalHits(totalHits, totalHitsRelation);
} else {
if (totalHits < trackTotalHitsUpTo) {