Log primary-replica resync failures

Today we do not fail a replica shard if the primary-replica resync to
that replica fails. Yet, we should at least log the failure
messages. This commit causes this to be the case.

Relates #27421
This commit is contained in:
Jason Tedor 2017-11-17 13:33:58 -05:00 committed by GitHub
parent db688e1a17
commit da115151a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,11 +18,13 @@
*/
package org.elasticsearch.action.resync;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.TransportActions;
import org.elasticsearch.action.support.replication.ReplicationOperation;
import org.elasticsearch.action.support.replication.ReplicationResponse;
import org.elasticsearch.action.support.replication.TransportReplicationAction;
import org.elasticsearch.action.support.replication.TransportWriteAction;
import org.elasticsearch.cluster.action.shard.ShardStateAction;
@ -158,6 +160,15 @@ public class TransportResyncReplicationAction extends TransportWriteAction<Resyn
@Override
public void handleResponse(ResyncReplicationResponse response) {
final ReplicationResponse.ShardInfo.Failure[] failures = response.getShardInfo().getFailures();
// noinspection ForLoopReplaceableByForEach
for (int i = 0; i < failures.length; i++) {
final ReplicationResponse.ShardInfo.Failure f = failures[i];
logger.info(
new ParameterizedMessage(
"{} primary-replica resync to replica on node [{}] failed", f.fullShardId(), f.nodeId()),
f.getCause());
}
listener.onResponse(response);
}