Browse Source

Search action now log in debug what shards/nodes were used before moving to second phase
Added a debug log for executing a refresh request on a shard.

Boaz Leskes 12 years ago
parent
commit
a48c437ffb

+ 1 - 0
src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java

@@ -113,6 +113,7 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
     protected ShardRefreshResponse shardOperation(ShardRefreshRequest request) throws ElasticSearchException {
         IndexShard indexShard = indicesService.indexServiceSafe(request.index()).shardSafe(request.shardId());
         indexShard.refresh(new Engine.Refresh().force(request.force()));
+        logger.debug("Refresh request executed for {}. Force: [{}].", indexShard.shardId(), request.force());
         return new ShardRefreshResponse(request.index(), request.shardId());
     }
 

+ 12 - 0
src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java

@@ -231,6 +231,7 @@ public abstract class TransportSearchTypeAction extends TransportAction<SearchRe
         void onFirstPhaseResult(int shardIndex, ShardRouting shard, FirstResult result, ShardIterator shardIt) {
             result.shardTarget(new SearchShardTarget(shard.currentNodeId(), shard.index(), shard.id()));
             processFirstPhaseResult(shardIndex, shard, result);
+
             // increment all the "future" shards to update the total ops since we some may work and some may not...
             // and when that happens, we break on total ops, so we must maintain them
             int xTotalOps = totalOps.addAndGet(shardIt.remaining() + 1);
@@ -387,6 +388,17 @@ public abstract class TransportSearchTypeAction extends TransportAction<SearchRe
         }
 
         final void innerMoveToSecondPhase() throws Exception {
+            if (logger.isDebugEnabled()) {
+                StringBuilder sb = new StringBuilder();
+                for (int i = 0; i < firstResults.length(); i++) {
+                    SearchShardTarget shard = firstResults.get(i).shardTarget();
+                    if (i > 0) {
+                        sb.append(",");
+                    }
+                    sb.append(shard);
+                }
+                logger.debug("Moving to second phase, based on results from: {}", sb);
+            }
             moveToSecondPhase();
         }
 

+ 1 - 1
src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java

@@ -386,7 +386,7 @@ public abstract class TransportShardReplicationOperationAction<Request extends S
                     continue;
                 }
                 if (!shard.active() || !clusterState.nodes().nodeExists(shard.currentNodeId())) {
-                    logger.debug("primary shard [{}] is not yet active or we do not know that node it is assigned to [{}]. Scheduling a retry.", shard.shardId(), shard.currentNodeId());
+                    logger.debug("primary shard [{}] is not yet active or we do not know the node it is assigned to [{}]. Scheduling a retry.", shard.shardId(), shard.currentNodeId());
                     retry(fromClusterEvent, null);
                     return false;
                 }