SOLR-14079: fix SPLITSHARD splitByPrefix in async mode

This commit is contained in:
yonik 2019-12-13 17:55:05 -05:00
parent db65c82c39
commit 5f8e65c58f
3 changed files with 24 additions and 2 deletions

View File

@ -315,6 +315,10 @@ Bug Fixes
* SOLR-14013: FIX: javabin performance regressions (noble, yonik, Houston Putman)
* SOLR-14079: SPLITSHARD splitByPrefix doesn't work in async mode. This also
affects splits triggered by the autoscale framework, which use async mode.
(Megan Carey, Andy Vuong, Bilal Waheed, Ilan Ginzburg, yonik)
Other Changes
---------------------

View File

@ -223,12 +223,11 @@ public class SplitShardCmd implements OverseerCollectionMessageHandler.Cmd {
// params.set(NUM_SUB_SHARDS, Integer.toString(numSubShards));
{
final ShardRequestTracker shardRequestTracker = ocmh.asyncRequestTracker(asyncId);
final ShardRequestTracker shardRequestTracker = ocmh.syncRequestTracker();
shardRequestTracker.sendShardRequest(parentShardLeader.getNodeName(), params, shardHandler);
SimpleOrderedMap<Object> getRangesResults = new SimpleOrderedMap<>();
String msgOnError = "SPLITSHARD failed to invoke SPLIT.getRanges core admin command";
shardRequestTracker.processResponses(getRangesResults, shardHandler, true, msgOnError);
handleFailureOnAsyncRequest(results, msgOnError);
// Extract the recommended splits from the shard response (if it exists)
// example response: getRangesResults={success={127.0.0.1:62086_solr={responseHeader={status=0,QTime=1},ranges=10-20,3a-3f}}}

View File

@ -148,6 +148,10 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
@Test
public void doTest() throws IOException, SolrServerException {
// SPLITSHARD is recommended to be run in async mode, so we default to that.
// Also, autoscale triggers use async with splits as well.
boolean doAsync = true;
CollectionAdminRequest
.createCollection(COLLECTION_NAME, "conf", 1, 1)
.setMaxShardsPerNode(100)
@ -165,6 +169,9 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
.setNumSubShards(2)
.setSplitByPrefix(true)
.setShardName("shard1");
if (doAsync) {
splitShard.setAsyncId("SPLIT1");
}
splitShard.process(client);
waitForState("Timed out waiting for sub shards to be active.",
COLLECTION_NAME, activeClusterShape(2, 3)); // expectedReplicas==3 because original replica still exists (just inactive)
@ -187,6 +194,9 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
splitShard = CollectionAdminRequest.splitShard(COLLECTION_NAME)
.setSplitByPrefix(true)
.setShardName("shard1_1"); // should start out with the range of 0-7fffffff
if (doAsync) {
splitShard.setAsyncId("SPLIT2");
}
splitShard.process(client);
waitForState("Timed out waiting for sub shards to be active.",
COLLECTION_NAME, activeClusterShape(3, 5));
@ -216,6 +226,9 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
splitShard = CollectionAdminRequest.splitShard(COLLECTION_NAME)
.setSplitByPrefix(true)
.setShardName(slice1.getName());
if (doAsync) {
splitShard.setAsyncId("SPLIT3");
}
splitShard.process(client);
waitForState("Timed out waiting for sub shards to be active.",
COLLECTION_NAME, activeClusterShape(4, 7));
@ -236,6 +249,9 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
splitShard = CollectionAdminRequest.splitShard(COLLECTION_NAME)
.setSplitByPrefix(true)
.setShardName(slice1.getName());
if (doAsync) {
splitShard.setAsyncId("SPLIT4");
}
splitShard.process(client);
waitForState("Timed out waiting for sub shards to be active.",
COLLECTION_NAME, activeClusterShape(5, 9));
@ -252,6 +268,9 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
splitShard = CollectionAdminRequest.splitShard(COLLECTION_NAME)
.setSplitByPrefix(true)
.setShardName(slice1.getName());
if (doAsync) {
splitShard.setAsyncId("SPLIT5");
}
splitShard.process(client);
waitForState("Timed out waiting for sub shards to be active.",
COLLECTION_NAME, activeClusterShape(6, 11));