summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-04-15 22:25:30 +0200
committerJon Bratseth <bratseth@gmail.com>2020-04-15 22:25:30 +0200
commitd0f7724d58a3b2cf72b26a9fc5fe3369287747fd (patch)
treea14e92c5c382caa7d78e6e49a608d6db56d88db4 /container-search
parent0c68f849c445c82e75ad439965e1b057cff5181e (diff)
Don't avoid group blocking feed when groups = 1
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java3
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java20
2 files changed, 18 insertions, 5 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
index 869ea6436de..9b42ce03e6d 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
@@ -249,11 +249,12 @@ public class Dispatcher extends AbstractComponent {
* We want to avoid groups blocking feed because their data may be out of date.
* If there is a single group blocking feed, we want to reject it.
* If multiple groups are blocking feed we should use them anyway as we may not have remaining
- * capacity otherwise.
+ * capacity otherwise. Same if there are no other groups.
*
* @return a modifiable set containing the single group to reject, or null otherwise
*/
private Set<Integer> rejectGroupBlockingFeed(List<Group> groups) {
+ if (groups.size() == 1) return null;
List<Group> groupsRejectingFeed = groups.stream().filter(Group::isBlockingWrites).collect(Collectors.toList());
if (groupsRejectingFeed.size() != 1) return null;
Set<Integer> rejected = new HashSet<>();
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
index aa7a0c6b4f4..eaafb2d8b8a 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
@@ -93,7 +93,7 @@ public class DispatcherTest {
}
@Test
- public void testGroup1IsSelected() {
+ public void testGroup0IsSelected() {
SearchCluster cluster = new MockSearchCluster("1", 3, 1);
Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
cluster.pingIterationCompleted();
@@ -103,7 +103,7 @@ public class DispatcherTest {
}
@Test
- public void testGroup1IsSkippedWhenItIsBlockingFeed() {
+ public void testGroup0IsSkippedWhenItIsBlockingFeed() {
SearchCluster cluster = new MockSearchCluster("1", 3, 1);
Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
cluster.group(0).get().nodes().get(0).setBlockingWrites(true);
@@ -115,8 +115,8 @@ public class DispatcherTest {
}
@Test
- public void testGroup1IsSelectedWhenMoreAreBlockingFeed() {
- SearchCluster cluster = new MockSearchCluster("1", 2, 1);
+ public void testGroup0IsSelectedWhenMoreAreBlockingFeed() {
+ SearchCluster cluster = new MockSearchCluster("1", 3, 1);
Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
cluster.group(0).get().nodes().get(0).setBlockingWrites(true);
cluster.group(1).get().nodes().get(0).setBlockingWrites(true);
@@ -127,6 +127,18 @@ public class DispatcherTest {
dispatcher.deconstruct();
}
+ @Test
+ public void testGroup0IsSelectedWhenItIsBlockingFeedWhenNoOthers() {
+ SearchCluster cluster = new MockSearchCluster("1", 1, 1);
+ Dispatcher dispatcher = new Dispatcher(new ClusterMonitor(cluster, false), cluster, createDispatchConfig(), new MockInvokerFactory(cluster, (n, a) -> true), new MockMetric());
+ cluster.group(0).get().nodes().get(0).setBlockingWrites(true);
+ cluster.pingIterationCompleted();
+ assertEquals("Blocking group is used when there is no alternative",
+ 0,
+ (dispatcher.getSearchInvoker(new Query(), null).distributionKey().get()).longValue());
+ dispatcher.deconstruct();
+ }
+
interface FactoryStep {
boolean returnInvoker(List<Node> nodes, boolean acceptIncompleteCoverage);
}