diff --git a/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java b/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java index 0c464d27e1957..709a6f27b0c26 100644 --- a/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java @@ -364,9 +364,10 @@ public void handleException(TransportException exp) { onCompletionListener.onResponse(response); }, e -> handleException(primaryShardReference, e)); + final IndexShard shard = primaryShardReference.indexShard; + final ActionListener globalCheckpointSyncingListener = ActionListener.wrap(response -> { if (syncGlobalCheckpointAfterOperation) { - final IndexShard shard = primaryShardReference.indexShard; try { shard.maybeSyncGlobalCheckpoint("post-operation"); } catch (final Exception e) { @@ -376,7 +377,8 @@ public void handleException(TransportException exp) { // intentionally swallow, a missed global checkpoint sync should not fail this operation logger.info( new ParameterizedMessage( - "{} failed to execute post-operation global checkpoint sync", shard.shardId()), e); + "{} failed to execute post-operation global checkpoint sync", + primaryShardReference.routingEntry().shardId()), e); } } }