-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Relax memory barrier from org.elasticsearch.action.search.AbstractSearchAsyncAction#hasShardResponse #124888
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
Relax memory barrier from org.elasticsearch.action.search.AbstractSearchAsyncAction#hasShardResponse #124888
Changes from all commits
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 |
|---|---|---|
|
|
@@ -494,7 +494,7 @@ private static boolean isTaskCancelledException(Exception e) { | |
| protected void onShardResult(Result result) { | ||
| assert result.getShardIndex() != -1 : "shard index is not set"; | ||
| assert result.getSearchShardTarget() != null : "search shard target must not be null"; | ||
| hasShardResponse.set(true); | ||
| hasShardResponse.compareAndExchangeRelease(false, true); | ||
| if (logger.isTraceEnabled()) { | ||
| logger.trace("got first-phase result from {}", result != null ? result.getSearchShardTarget() : null); | ||
| } | ||
|
|
@@ -734,7 +734,7 @@ protected final ShardSearchRequest buildShardSearchRequest(SearchShardIterator s | |
| // can return a null response if the request rewrites to match none rather | ||
| // than creating an empty response in the search thread pool. | ||
| // Note that, we have to disable this shortcut for queries that create a context (scroll and search context). | ||
| shardRequest.canReturnNullResponseIfMatchNoDocs(hasShardResponse.get() && shardRequest.scroll() == null); | ||
| shardRequest.canReturnNullResponseIfMatchNoDocs(shardRequest.scroll() == null && hasShardResponse.getAcquire()); | ||
|
Contributor
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. Is the order swap of the acquire call and the shardRequest.scroll() call on purpose? If so, can you document why ?
Contributor
Author
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. Hmm not sure it makes sense to add a comment for this, obviously a potentially shared read is more expensive than a plain read so I figured I'd just switch these two around? :No magic here ) |
||
| return shardRequest; | ||
| } | ||
|
|
||
|
|
||
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.
Can you please document why acquire semantics are not needed here?
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.
Hmm same question here, does it really make sense to document this? We have no data dependency between this field and any other field and we only go false -> true here so if we do a plain read that's good enough, a potentially redundant write is still an improvement of the previous version. Maybe we should come up with a general list of what to use for what instead?