From c1264b926fb3967f7d2d25f1576549b304ffeab3 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Fri, 20 Nov 2015 21:50:32 +0100 Subject: [PATCH] Improve trace logging in TransportReplicationAction and error reporting at RecoveryWhileUnderLoadIT Things that helped me traced down an issue. Closes #14931 --- .../TransportReplicationAction.java | 38 +++++++++++-------- .../recovery/RecoveryWhileUnderLoadIT.java | 24 +++++++++--- .../elasticsearch/test/BackgroundIndexer.java | 1 + 3 files changed, 42 insertions(+), 21 deletions(-) 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 23bf21bd83a..805778ccdeb 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 @@ -275,7 +275,7 @@ public abstract class TransportReplicationAction primaryResponse = shardOperationOnPrimary(observer.observedState(), por); - logger.trace("operation completed on primary [{}]", primary); + if (logger.isTraceEnabled()) { + logger.trace("operation completed on primary [{}], action [{}], request [{}], cluster state version [{}]", primary, actionName, por.request, observer.observedState().version()); + } replicationPhase = new ReplicationPhase(shardsIt, primaryResponse.v2(), primaryResponse.v1(), observer, primary, internalRequest, listener, indexShardReference, shardFailedTimeout); } catch (Throwable e) { // shard has not been allocated yet, retry it here if (retryPrimaryException(e)) { - logger.trace("had an error while performing operation on primary ({}), scheduling a retry.", e.getMessage()); + logger.trace("had an error while performing operation on primary ({}, action [{}], request [{}]), scheduling a retry.", e, primary, actionName, internalRequest.request); // We have to close here because when we retry we will increment get a new reference on index shard again and we do not want to // increment twice. Releasables.close(indexShardReference); @@ -650,8 +654,8 @@ public abstract class TransportReplicationAction trying to wait"); assertTrue(awaitBusy(() -> { diff --git a/test-framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java b/test-framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java index 764c85657d7..933f26e6e81 100644 --- a/test-framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java +++ b/test-framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java @@ -195,6 +195,7 @@ public class BackgroundIndexer implements AutoCloseable { XContentBuilder builder = XContentFactory.smileBuilder(); builder.startObject().field("test", "value" + id) .field("text", text.toString()) + .field("id", id) .endObject(); return builder;