fix a (rare) case where search will fail due to failed serialization
This commit is contained in:
parent
b4e5a542f3
commit
ba725f8986
|
@ -50,13 +50,17 @@ public class SearchPhaseExecutionException extends ElasticSearchException {
|
|||
return shardFailures;
|
||||
}
|
||||
|
||||
private static final String buildMessage(String phaseName, String msg, ShardSearchFailure[] shardFailures) {
|
||||
private static String buildMessage(String phaseName, String msg, ShardSearchFailure[] shardFailures) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Failed to execute phase [").append(phaseName).append("], ").append(msg);
|
||||
if (shardFailures != null && shardFailures.length > 0) {
|
||||
sb.append("; shardFailures ");
|
||||
for (ShardSearchFailure shardFailure : shardFailures) {
|
||||
sb.append("{").append(shardFailure.shard()).append(": ").append(shardFailure.reason()).append("}");
|
||||
if (shardFailure.shard() != null) {
|
||||
sb.append("{").append(shardFailure.shard()).append(": ").append(shardFailure.reason()).append("}");
|
||||
} else {
|
||||
sb.append("{").append(shardFailure.reason()).append("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -49,11 +50,11 @@ public class SearchShardTarget implements Streamable, Serializable {
|
|||
this.shardId = shardId;
|
||||
}
|
||||
|
||||
public String nodeId() {
|
||||
@Nullable public String nodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public String getNodeId() {
|
||||
@Nullable public String getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
|
@ -80,13 +81,20 @@ public class SearchShardTarget implements Streamable, Serializable {
|
|||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
nodeId = in.readUTF();
|
||||
if (in.readBoolean()) {
|
||||
nodeId = in.readUTF();
|
||||
}
|
||||
index = in.readUTF();
|
||||
shardId = in.readVInt();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeUTF(nodeId);
|
||||
if (nodeId == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(nodeId);
|
||||
}
|
||||
out.writeUTF(index);
|
||||
out.writeVInt(shardId);
|
||||
}
|
||||
|
@ -112,6 +120,9 @@ public class SearchShardTarget implements Streamable, Serializable {
|
|||
}
|
||||
|
||||
@Override public String toString() {
|
||||
if (nodeId == null) {
|
||||
return "[_na_][" + index + "][" + shardId + "]";
|
||||
}
|
||||
return "[" + nodeId + "][" + index + "][" + shardId + "]";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue