Add shard ID to failed global checkpoint messages

When a global checkpoint sync fails we should log the shard ID for the
shard the sync failed for. This commit causes this to be the case.
This commit is contained in:
Jason Tedor 2017-09-25 14:32:55 -04:00
parent ec0c621072
commit 57aee93693
3 changed files with 14 additions and 6 deletions

View File

@ -379,12 +379,17 @@ public abstract class TransportReplicationAction<
@Override
public void onResponse(Response response) {
if (syncGlobalCheckpointAfterOperation) {
final IndexShard shard = primaryShardReference.indexShard;
try {
primaryShardReference.indexShard.maybeSyncGlobalCheckpoint("post-operation");
shard.maybeSyncGlobalCheckpoint("post-operation");
} catch (final Exception e) {
// only log non-closed exceptions
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
logger.info("post-operation global checkpoint sync failed", e);
logger.info(
new ParameterizedMessage(
"{} failed to execute background global checkpoint sync",
shard.shardId()),
e);
// intentionally swallow, a missed global checkpoint sync should not fail this operation
}
}

View File

@ -747,7 +747,11 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
},
e -> {
if (!(e instanceof AlreadyClosedException || e instanceof IndexShardClosedException)) {
logger.info("failed to execute background global checkpoint sync", e);
logger.info(
new ParameterizedMessage(
"{} failed to execute background global checkpoint sync",
shard.shardId()),
e);
}
}),
ThreadPool.Names.SAME);

View File

@ -19,10 +19,10 @@
package org.elasticsearch.index.seqno;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.lucene.store.AlreadyClosedException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.replication.ReplicationOperation;
@ -35,7 +35,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.shard.IndexEventListener;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.IndexShardClosedException;
import org.elasticsearch.index.shard.ShardId;
@ -85,7 +84,7 @@ public class GlobalCheckpointSyncAction extends TransportReplicationAction<
new Request(shardId),
ActionListener.wrap(r -> {}, e -> {
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
logger.info(shardId + " global checkpoint sync failed", e);
logger.info(new ParameterizedMessage("{} global checkpoint sync failed", shardId), e);
}
}));
}