Skip to content

Commit e00cc7b

Browse files
cpoerschketboeghk
andauthored
SOLR-17337: Show proper distributed stage id (#2594)
Co-authored-by: Torsten Bøgh Köster <[email protected]>
1 parent 57287c8 commit e00cc7b

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

solr/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ Bug Fixes
212212

213213
* SOLR-17369: Fix "flags" usage in FunctionQParser that caused some issues in vectorSimilarity() with BYTE vector constants (hossman)
214214

215+
* SOLR-17337: Display all custom distributed stages in debug output. (Torsten Bøgh Köster, Christine Poerschke)
216+
215217
Dependency Upgrades
216218
---------------------
217219
(No changes)

solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.apache.solr.common.params.CommonParams.FQ;
2020
import static org.apache.solr.common.params.CommonParams.JSON;
2121

22+
import com.google.common.annotations.VisibleForTesting;
2223
import java.io.IOException;
2324
import java.lang.reflect.Array;
2425
import java.util.ArrayList;
@@ -181,16 +182,28 @@ public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest
181182
}
182183
}
183184

185+
@VisibleForTesting
186+
protected String getDistributedStageName(int stage) {
187+
String stageName = stages.get(stage);
188+
189+
if (stageName == null) {
190+
stageName = "STAGE_" + Integer.toString(stage);
191+
}
192+
193+
return stageName;
194+
}
195+
184196
@Override
185197
public void handleResponses(ResponseBuilder rb, ShardRequest sreq) {
186198
if (rb.isDebugTrack() && rb.isDistrib && !rb.finished.isEmpty()) {
187199
@SuppressWarnings("unchecked")
188200
NamedList<Object> stageList =
189201
(NamedList<Object>)
190-
((NamedList<Object>) rb.getDebugInfo().get("track")).get(stages.get(rb.stage));
202+
((NamedList<Object>) rb.getDebugInfo().get("track"))
203+
.get(getDistributedStageName(rb.stage));
191204
if (stageList == null) {
192205
stageList = new SimpleOrderedMap<>();
193-
rb.addDebug(stageList, "track", stages.get(rb.stage));
206+
rb.addDebug(stageList, "track", getDistributedStageName(rb.stage));
194207
}
195208
for (ShardResponse response : sreq.responses) {
196209
stageList.add(response.getShard(), getTrackResponse(response));

solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,14 @@ private void addRequestId(ResponseBuilder rb, String requestId) {
297297
params.add(CommonParams.REQUEST_ID, requestId);
298298
rb.req.setParams(params);
299299
}
300+
301+
@Test
302+
public void testDistributedStageResolution() throws IOException {
303+
final DebugComponent debugComponent = new DebugComponent();
304+
assertEquals(
305+
"PARSE_QUERY", debugComponent.getDistributedStageName(ResponseBuilder.STAGE_PARSE_QUERY));
306+
assertEquals("DONE", debugComponent.getDistributedStageName(ResponseBuilder.STAGE_DONE));
307+
assertEquals("STAGE_400", debugComponent.getDistributedStageName(400));
308+
assertEquals("STAGE_10000", debugComponent.getDistributedStageName(10000));
309+
}
300310
}

0 commit comments

Comments
 (0)