Skip to content
Closed
Changes from all commits
Commits
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 @@ -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);
Copy link
Contributor

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?

Copy link
Contributor Author

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?

if (logger.isTraceEnabled()) {
logger.trace("got first-phase result from {}", result != null ? result.getSearchShardTarget() : null);
}
Expand Down Expand Up @@ -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());
Copy link
Contributor

Choose a reason for hiding this comment

The 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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
}

Expand Down