Skip to content

Commit bb6c031

Browse files
committed
Search: A failed search request might get overrun when trying another shard, closes elastic#1403.
1 parent 5023e9a commit bb6c031

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/action/search/SearchRequest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ public SearchRequest(String[] indices, byte[] source) {
119119
return validationException;
120120
}
121121

122-
/**
123-
* Internal.
124-
*/
125-
public void beforeLocalFork() {
122+
public void beforeStart() {
123+
// we always copy over if needed, the reason is that a request might fail while being search remotely
124+
// and then we need to keep the buffer around
126125
if (source != null && sourceUnsafe) {
127126
source = Arrays.copyOfRange(source, sourceOffset, sourceOffset + sourceLength);
128127
sourceOffset = 0;
@@ -135,6 +134,12 @@ public void beforeLocalFork() {
135134
}
136135
}
137136

137+
/**
138+
* Internal.
139+
*/
140+
public void beforeLocalFork() {
141+
}
142+
138143
/**
139144
* Should the listener be called on a separate thread if needed.
140145
*/

modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ protected BaseAsyncAction(SearchRequest request, ActionListener<SearchResponse>
130130
}
131131

132132
public void start() {
133+
request.beforeStart();
133134
// count the local operations, and perform the non local ones
134135
int localOperations = 0;
135136
for (final ShardIterator shardIt : shardsIts) {

0 commit comments

Comments
 (0)