Skip to content

Commit

Permalink
Fix occasional SearchServiceTests failure (#39697)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Christoph Büscher committed Mar 6, 2019
1 parent f8015f2 commit bb7f276
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.elasticsearch.search;

import com.carrotsearch.hppc.IntArrayList;

import org.apache.lucene.search.Query;
import org.apache.lucene.store.AlreadyClosedException;
import org.elasticsearch.ElasticsearchException;
Expand Down Expand Up @@ -198,7 +199,8 @@ public void testClearIndexDelete() {
}

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

SearchService service = getInstanceFromNode(SearchService.class);
Expand Down

0 comments on commit bb7f276

Please sign in to comment.