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

SOLR-15892: Adding Randomization in selecting shard leaders for delete and commit requests for RoutedAlias #2636

Open
wants to merge 1 commit into
base: branch_8_11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Expand Up @@ -57,6 +57,8 @@ Bug Fixes

* SOLR-15324: Upgrade jaegertracing to 1.6.0 and libthrift to 0.14.1 (wcmrnd1, janhoy)

* SOLR-15892: Adding Randomization in selecting shard leaders for delete and commit requests for RoutedAlias

================== 8.11.0 ==================

Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -86,6 +87,8 @@ public class RoutedAliasUpdateProcessor extends UpdateRequestProcessor {
private final RoutedAlias routedAlias;
private final SolrParams outParamsToLeader;

private static final Random random = new Random();


public static UpdateRequestProcessor wrap(SolrQueryRequest req, UpdateRequestProcessor next) {
String aliasName = null;
Expand Down Expand Up @@ -254,7 +257,7 @@ private SolrCmdDistributor.Node lookupShardLeaderOfCollection(String collection)
if (activeSlices.length == 0) {
throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Cannot route to collection " + collection);
}
final Slice slice = activeSlices[0];
final Slice slice = activeSlices[random.nextInt(activeSlices.length)];
return getLeaderNode(collection, slice);
}

Expand Down