-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Changes from 5 commits
02f1fa8
9e69711
5ee2b02
c0e5b67
f3006a5
683786d
2834af8
4ad2bed
644fa60
7e0df4a
a22b341
614d85e
a02f332
aac9d4b
836af1c
2dc6699
16e295e
605a4dc
4a90174
9ce9be8
e76deba
048eea6
a429c21
d2cf1a2
d0a48e3
fca7ae9
14499b0
6f7aafa
4c8e50c
df3e416
cc6d1e9
7ca22c5
f376eab
33a04b5
ef961bd
97ea739
7df7358
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
import org.opensearch.cluster.routing.GroupShardsIterator; | ||
import org.opensearch.cluster.routing.ShardIterator; | ||
import org.opensearch.cluster.routing.ShardRouting; | ||
import org.opensearch.cluster.routing.WeightedRoutingHelper; | ||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.Nullable; | ||
import org.opensearch.common.inject.Inject; | ||
|
@@ -261,24 +262,43 @@ private void onFailure(ShardRouting shardRouting, Exception e) { | |
tryNext(e, false); | ||
} | ||
|
||
private ShardRouting nextRoutingOrNull() { | ||
private ShardRouting nextRoutingOrNull(Exception failure) { | ||
if (shardsIt.size() == 0 || shardIndex >= shardsIt.size()) { | ||
return null; | ||
} | ||
ShardRouting next = shardsIt.get(shardIndex).nextOrNull(); | ||
|
||
// This checks if the shard is present in data node with weighted routing weight set to 0, | ||
// In such cases we fail open, if shard search request for the shard from other shard copies fail with non | ||
// retryable exception. | ||
while (next != null && WeightedRoutingHelper.shardInWeighedAwayAZ(next.currentNodeId(), clusterService.state())) { | ||
if (WeightedRoutingHelper.isInternalFailure(failure)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I strongly feel we should add allow searches in weighed away nodes, when there are unassigned copies of that shard as well . This would prevent unnecessary 4XX to the user . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah makes sense. I can add that check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets avoid redundant handling of logic |
||
ShardRouting shardToFailOpen = next; | ||
logger.info( | ||
() -> new ParameterizedMessage( | ||
"{}: Fail open executed", | ||
shardToFailOpen.shardId() | ||
|
||
) | ||
); | ||
break; | ||
} | ||
next = shardsIt.get(shardIndex).nextOrNull(); | ||
} | ||
|
||
if (next != null) { | ||
return next; | ||
} | ||
moveToNextShard(); | ||
return nextRoutingOrNull(); | ||
return nextRoutingOrNull(failure); | ||
} | ||
|
||
private void moveToNextShard() { | ||
++shardIndex; | ||
} | ||
|
||
private void tryNext(@Nullable final Exception lastFailure, boolean canMatchShard) { | ||
ShardRouting shardRouting = nextRoutingOrNull(); | ||
ShardRouting shardRouting = nextRoutingOrNull(lastFailure); | ||
if (shardRouting == null) { | ||
if (canMatchShard == false) { | ||
listener.onResponse(new FieldCapabilitiesIndexResponse(request.index(), Collections.emptyMap(), false)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note : we should test out cross cluster search works with this as well .