Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ public void testRewriteCompoundRetrieverShouldThrowForPartialResults() throws Ex
SearchPhaseExecutionException.class,
client().prepareSearch(testIndex).setSource(source)::get
);
assertThat(
ex.getDetailedMessage(),
containsString("[open_point_in_time] action requires all shards to be available. Missing shards")
);
assertThat(ex.getDetailedMessage(), containsString("Search rejected due to missing shards"));
} finally {
internalCluster().restartNode(randomDataNode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private synchronized void consumeResult(int shardIndex, boolean canMatch, MinAnd

private void checkNoMissingShards(List<SearchShardIterator> shards) {
assert assertSearchCoordinationThread();
SearchPhase.doCheckNoMissingShards("can_match", request, shards, SearchPhase::makeMissingShardsError);
SearchPhase.doCheckNoMissingShards("can_match", request, shards);
}

private Map<SendingTarget, List<SearchShardIterator>> groupByNode(List<SearchShardIterator> shards) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import java.util.List;
import java.util.Objects;
import java.util.function.Function;

/**
* Base class for all individual search phases like collecting distributed frequencies, fetching documents, querying shards.
Expand All @@ -35,26 +34,13 @@ public String getName() {
return name;
}

protected String missingShardsErrorMessage(StringBuilder missingShards) {
return makeMissingShardsError(missingShards);
}

protected static String makeMissingShardsError(StringBuilder missingShards) {
private static String makeMissingShardsError(StringBuilder missingShards) {
return "Search rejected due to missing shards ["
+ missingShards
+ "]. Consider using `allow_partial_search_results` setting to bypass this error.";
}

protected void doCheckNoMissingShards(String phaseName, SearchRequest request, List<SearchShardIterator> shardsIts) {
doCheckNoMissingShards(phaseName, request, shardsIts, this::missingShardsErrorMessage);
}

protected static void doCheckNoMissingShards(
String phaseName,
SearchRequest request,
List<SearchShardIterator> shardsIts,
Function<StringBuilder, String> makeErrorMessage
) {
protected static void doCheckNoMissingShards(String phaseName, SearchRequest request, List<SearchShardIterator> shardsIts) {
assert request.allowPartialSearchResults() != null : "SearchRequest missing setting for allowPartialSearchResults";
if (request.allowPartialSearchResults() == false) {
final StringBuilder missingShards = new StringBuilder();
Expand All @@ -70,7 +56,7 @@ protected static void doCheckNoMissingShards(
}
if (missingShards.isEmpty() == false) {
// Status red - shard is missing all copies and would produce partial results for an index search
final String msg = makeErrorMessage.apply(missingShards);
final String msg = makeMissingShardsError(missingShards);
throw new SearchPhaseExecutionException(phaseName, msg, null, ShardSearchFailure.EMPTY_ARRAY);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ void runOpenPointInTimePhase(
searchRequest.getMaxConcurrentShardRequests(),
clusters
) {
protected String missingShardsErrorMessage(StringBuilder missingShards) {
return "[open_point_in_time] action requires all shards to be available. Missing shards: ["
+ missingShards
+ "]. Consider using `allow_partial_search_results` setting to bypass this error.";
}

@Override
protected void executePhaseOnShard(
SearchShardIterator shardIt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void createTestIndex() throws IOException {
public void testPartialResponseHandling() throws SQLException {
try (Connection c = esJdbc(); Statement s = c.createStatement()) {
SQLException exception = expectThrows(SQLException.class, () -> s.executeQuery("SELECT * FROM test ORDER BY test_field ASC"));
assertThat(exception.getMessage(), containsString("[open_point_in_time] action requires all shards to be available"));
assertThat(exception.getMessage(), containsString("Search rejected due to missing shards"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testPartialResponseHandling() throws Exception {
createTestIndex();
try (Connection c = esJdbc(); Statement s = c.createStatement()) {
SQLException exception = expectThrows(SQLException.class, () -> s.executeQuery("SELECT * FROM test ORDER BY test_field ASC"));
assertThat(exception.getMessage(), containsString("[open_point_in_time] action requires all shards to be available"));
assertThat(exception.getMessage(), containsString("Search rejected due to missing shards"));
}
}

Expand Down