diff --git a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java index 77f7ff1d446..7dfe10a7753 100644 --- a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java @@ -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 } } diff --git a/core/src/main/java/org/elasticsearch/index/IndexService.java b/core/src/main/java/org/elasticsearch/index/IndexService.java index ae5ea432855..d192e8781d6 100644 --- a/core/src/main/java/org/elasticsearch/index/IndexService.java +++ b/core/src/main/java/org/elasticsearch/index/IndexService.java @@ -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); diff --git a/core/src/main/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncAction.java b/core/src/main/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncAction.java index 60b61ccefa5..3570ade09ad 100644 --- a/core/src/main/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncAction.java +++ b/core/src/main/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncAction.java @@ -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); } })); }