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

[Weighted Shard Routing] Fail open requests on search shard failures #5072

Merged
merged 37 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
02f1fa8
Fail open changes
Nov 9, 2022
9e69711
Refactor code
Nov 10, 2022
5ee2b02
Merge branch 'main' into feature/poc-fail-open
Nov 10, 2022
c0e5b67
Fix test
Nov 10, 2022
f3006a5
Add integ test with network disruption and refactor code
Nov 10, 2022
683786d
Merge branch 'main' into feature/poc-fail-open
Dec 6, 2022
2834af8
Add log statement
Dec 6, 2022
4ad2bed
Add integ test for search aggregations and flag open flag
Dec 20, 2022
644fa60
Refactor integ tests
Dec 21, 2022
7e0df4a
Add integ test for multiget with fail open
Dec 21, 2022
a22b341
Add changelog
Dec 21, 2022
614d85e
Refactor code
Dec 27, 2022
a02f332
Make fail open enabled by default
Dec 27, 2022
aac9d4b
Fail open on unassigned shard copies
Dec 28, 2022
836af1c
Add tests
Dec 30, 2022
2dc6699
Fix tests
Dec 30, 2022
16e295e
Merge branch 'main' into feature/poc-fail-open
Dec 30, 2022
605a4dc
Fix precommit build
Jan 2, 2023
4a90174
Fix test
Jan 2, 2023
9ce9be8
Change internal error logic to check for 5xx status
Jan 3, 2023
e76deba
Fix test
Jan 3, 2023
048eea6
Merge branch 'main' into feature/poc-fail-open
Jan 4, 2023
a429c21
Fix integ test failure
Jan 4, 2023
d2cf1a2
Merge branch 'main' into feature/poc-fail-open
Jan 5, 2023
d0a48e3
Address review comments
Jan 6, 2023
fca7ae9
Fix precommit failure
Jan 6, 2023
14499b0
Merge branch 'main' into feature/poc-fail-open
Jan 8, 2023
6f7aafa
Merge branch 'main' into feature/poc-fail-open
Jan 9, 2023
4c8e50c
Fix tests
Jan 9, 2023
df3e416
Modify changelog
Jan 9, 2023
cc6d1e9
Address review comments
Jan 9, 2023
7ca22c5
Remove duplicate shards from routing interator
Jan 9, 2023
f376eab
add test to valiate request state persistence
Jan 9, 2023
33a04b5
fix test comment
Jan 9, 2023
ef961bd
Address review comments
Jan 9, 2023
97ea739
log exception
Jan 9, 2023
7df7358
Address review comments
Jan 10, 2023
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 @@ -54,6 +54,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -325,6 +326,7 @@ public ShardIterator activeInitializingShardsWeightedIt(
final int seed = shuffler.nextSeed();
List<ShardRouting> ordered = new ArrayList<>();
List<ShardRouting> orderedActiveShards = getActiveShardsByWeight(weightedRouting, nodes, defaultWeight);
List<ShardRouting> orderedListWithDistinctShards;
ordered.addAll(shuffler.shuffle(orderedActiveShards, seed));
if (!allInitializingShards.isEmpty()) {
List<ShardRouting> orderedInitializingShards = getInitializingShardsByWeight(weightedRouting, nodes, defaultWeight);
Expand Down Expand Up @@ -352,8 +354,8 @@ public ShardIterator activeInitializingShardsWeightedIt(
logger.debug("no shard copies found for shard id [{}] for node attribute with weight zero", shardId);
}
}

return new PlainShardIterator(shardId, ordered);
orderedListWithDistinctShards = new ArrayList<>(new LinkedHashSet<>(ordered));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest

ordered.stream().distinct().collect(Collectors.toList())

return new PlainShardIterator(shardId, orderedListWithDistinctShards);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ public void testWeightedRoutingWithDifferentWeights() {
shardRouting = shardIterator.nextOrNull();
assertNotNull(shardRouting);
assertFalse(Arrays.asList("node2", "node1").contains(shardRouting.currentNodeId()));

weights = Map.of("zone1", 3.0, "zone2", 2.0, "zone3", 0.0);
weightedRouting = new WeightedRouting("zone", weights);
shardIterator = clusterState.routingTable()
.index("test")
.shard(0)
.activeInitializingShardsWeightedIt(weightedRouting, clusterState.nodes(), 1, true);
assertEquals(3, shardIterator.size());
shardRouting = shardIterator.nextOrNull();
assertNotNull(shardRouting);
} finally {
terminate(threadPool);
}
Expand Down