Skip to content

Commit 5644551

Browse files
Fix SearchStatesIT.testCanMatch (elastic#120046)
Adding back the old style free request to fix CCS BwC situations where we need to proxy requests exactly as is and can't drop the technically redundant original indices. closes elastic#118718
1 parent b398ad6 commit 5644551

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,6 @@ tests:
400400
- class: org.elasticsearch.xpack.restart.FullClusterRestartIT
401401
method: testWatcherWithApiKey {cluster=UPGRADED}
402402
issue: https://github.com/elastic/elasticsearch/issues/119396
403-
- class: org.elasticsearch.upgrades.SearchStatesIT
404-
method: testCanMatch
405-
issue: https://github.com/elastic/elasticsearch/issues/118718
406403
- class: org.elasticsearch.search.profile.dfs.DfsProfilerIT
407404
method: testProfileDfs
408405
issue: https://github.com/elastic/elasticsearch/issues/119711

server/src/main/java/org/elasticsearch/action/search/SearchTransportService.java

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import org.apache.logging.log4j.Logger;
1414
import org.elasticsearch.action.ActionListener;
1515
import org.elasticsearch.action.ActionListenerResponseHandler;
16+
import org.elasticsearch.action.IndicesRequest;
1617
import org.elasticsearch.action.OriginalIndices;
1718
import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest;
1819
import org.elasticsearch.action.admin.cluster.node.tasks.get.TransportGetTaskAction;
1920
import org.elasticsearch.action.support.ChannelActionListener;
21+
import org.elasticsearch.action.support.IndicesOptions;
2022
import org.elasticsearch.client.internal.OriginSettingClient;
2123
import org.elasticsearch.client.internal.node.NodeClient;
2224
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -350,6 +352,38 @@ private static class ClearScrollContextsRequest extends TransportRequest {
350352
}
351353
}
352354

355+
static class SearchFreeContextRequest extends ScrollFreeContextRequest implements IndicesRequest {
356+
private final OriginalIndices originalIndices;
357+
358+
SearchFreeContextRequest(StreamInput in) throws IOException {
359+
super(in);
360+
originalIndices = OriginalIndices.readOriginalIndices(in);
361+
}
362+
363+
@Override
364+
public void writeTo(StreamOutput out) throws IOException {
365+
super.writeTo(out);
366+
OriginalIndices.writeOriginalIndices(originalIndices, out);
367+
}
368+
369+
@Override
370+
public String[] indices() {
371+
if (originalIndices == null) {
372+
return null;
373+
}
374+
return originalIndices.indices();
375+
}
376+
377+
@Override
378+
public IndicesOptions indicesOptions() {
379+
if (originalIndices == null) {
380+
return null;
381+
}
382+
return originalIndices.indicesOptions();
383+
}
384+
385+
}
386+
353387
public static class SearchFreeContextResponse extends TransportResponse {
354388

355389
private static final SearchFreeContextResponse FREED = new SearchFreeContextResponse(true);
@@ -400,12 +434,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
400434
);
401435

402436
// TODO: remove this handler once the lowest compatible version stops using it
403-
transportService.registerRequestHandler(FREE_CONTEXT_ACTION_NAME, freeContextExecutor, in -> {
404-
var res = new ScrollFreeContextRequest(in);
405-
// this handler exists for BwC purposes only, we don't need the original indices to free the context
406-
OriginalIndices.readOriginalIndices(in);
407-
return res;
408-
}, freeContextHandler);
437+
// this handler exists for BwC purposes only, we don't need the original indices to free the context
438+
transportService.registerRequestHandler(
439+
FREE_CONTEXT_ACTION_NAME,
440+
freeContextExecutor,
441+
SearchFreeContextRequest::new,
442+
freeContextHandler
443+
);
409444
TransportActionProxy.registerProxyAction(transportService, FREE_CONTEXT_ACTION_NAME, false, SearchFreeContextResponse::readFrom);
410445

411446
transportService.registerRequestHandler(

0 commit comments

Comments
 (0)