Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facet refine handle unknown shard. (#238) #241

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ public void newShard(String shard) {
this.bucketWasMissing = false;
}

public void setShard(String shard) {
this.shardNum = shardmap.get(shard);
public boolean setShard(String shard) {
Integer shardNum = shardmap.get(shard);
boolean hasShard = shardNum != null;
this.shardNum = hasShard ? shardNum : -1;
return hasShard;
}

public int getNewBucketNumber() {
Expand Down
15 changes: 13 additions & 2 deletions solr/core/src/java/org/apache/solr/search/facet/FacetModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ public int distributedProcess(ResponseBuilder rb) throws IOException {

assert rb.shards.length == facetState.mcontext.numShards;
for (String shard : rb.shards) {
facetState.mcontext.setShard(shard);
if (!facetState.mcontext.setShard(shard)) {
// for some reason or another (most likely a failed shard request),
// we do not know about this shard
// there is no need to make a refinement request
// as we didn't even complete the initial request
continue;
}

// shard-specific refinement
Map<String, Object> refinement = facetState.merger.getRefinement(facetState.mcontext);
Expand Down Expand Up @@ -316,7 +322,12 @@ public void handleResponses(ResponseBuilder rb, ShardRequest sreq) {
// System.err.println("REFINE FACET RESULT FROM SHARD = " + facet);
// call merge again with a diff flag set on the context???
facetState.mcontext.root = facet;
facetState.mcontext.setShard(shardRsp.getShard()); // TODO: roll newShard into setShard?
if (!facetState.mcontext.setShard(
shardRsp.getShard())) { // TODO: roll newShard into setShard?
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
"received refinement results for unknown shard: " + shardRsp.getShard());
}
facetState.merger.merge(facet, facetState.mcontext);
return;
}
Expand Down
Loading