Skip to content

Commit bb7f276

Browse files
author
Christoph Büscher
committed
Fix occasional SearchServiceTests failure (#39697)
Currently SearchServiceTests.testCloseSearchContextOnRewriteException can fail if a refresh happens while we test for the SearchPhaseExecutionException that is thrown later in the test. The test takes the current Store#refCount and expects it to be the same after the exception is thrown. If a refresh happens in that interval however, the refCound will be different, causing the test to fail. This can be provoked e.g. by running this section in a tight loop. Switching of refresh for this tests solves the issue.
1 parent f8015f2 commit bb7f276

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/test/java/org/elasticsearch/search/SearchServiceTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.elasticsearch.search;
2020

2121
import com.carrotsearch.hppc.IntArrayList;
22+
2223
import org.apache.lucene.search.Query;
2324
import org.apache.lucene.store.AlreadyClosedException;
2425
import org.elasticsearch.ElasticsearchException;
@@ -198,7 +199,8 @@ public void testClearIndexDelete() {
198199
}
199200

200201
public void testCloseSearchContextOnRewriteException() {
201-
createIndex("index");
202+
// if refresh happens while checking the exception, the subsequent reference count might not match, so we switch it off
203+
createIndex("index", Settings.builder().put("index.refresh_interval", -1).build());
202204
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
203205

204206
SearchService service = getInstanceFromNode(SearchService.class);

0 commit comments

Comments
 (0)