Skip to content

Commit 84d520b

Browse files
committed
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 #37179 which seems to fail only in CI. The assertion will be restored when the issue is solved (NORELEASE).
1 parent dc371ef commit 84d520b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

server/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,13 @@ TotalHits getTotalHits() {
760760
if (trackTotalHitsUpTo == SearchContext.TRACK_TOTAL_HITS_DISABLED) {
761761
return null;
762762
} else if (trackTotalHitsUpTo == SearchContext.TRACK_TOTAL_HITS_ACCURATE) {
763-
assert totalHitsRelation == Relation.EQUAL_TO;
763+
// NORELEASE The assertion below has been replaced by a runtime exception in order to debug
764+
// https://github.com/elastic/elasticsearch/issues/37179.
765+
// The assertion should be restored and the exception removed when this issue is solved.
766+
// assert totalHitsRelation == Relation.EQUAL_TO;
767+
if (totalHitsRelation != Relation.EQUAL_TO) {
768+
throw new IllegalStateException("Expected accurate total hits but got " + new TotalHits(totalHits, totalHitsRelation));
769+
}
764770
return new TotalHits(totalHits, totalHitsRelation);
765771
} else {
766772
if (totalHits < trackTotalHitsUpTo) {

0 commit comments

Comments
 (0)