Skip to content

Commit 4cc9f5d

Browse files
authored
Revert Remove direct cloning of BytesTransportRequests (#117200)
Reverts #114808 and unmutes #117024 which was a related failure.
1 parent 4f46924 commit 4cc9f5d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,6 @@ tests:
237237
- class: org.elasticsearch.upgrades.QueryBuilderBWCIT
238238
method: testQueryBuilderBWC {cluster=UPGRADED}
239239
issue: https://github.com/elastic/elasticsearch/issues/116990
240-
- class: org.elasticsearch.discovery.ClusterDisruptionIT
241-
method: testAckedIndexing
242-
issue: https://github.com/elastic/elasticsearch/issues/117024
243240
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
244241
method: test {yaml=reference/esql/esql-across-clusters/line_197}
245242
issue: https://github.com/elastic/elasticsearch/issues/117099

test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.elasticsearch.core.RefCounted;
4040
import org.elasticsearch.core.Strings;
4141
import org.elasticsearch.core.TimeValue;
42+
import org.elasticsearch.core.UpdateForV9;
4243
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
4344
import org.elasticsearch.node.Node;
4445
import org.elasticsearch.plugins.Plugin;
@@ -49,6 +50,7 @@
4950
import org.elasticsearch.test.ESTestCase;
5051
import org.elasticsearch.test.tasks.MockTaskManager;
5152
import org.elasticsearch.threadpool.ThreadPool;
53+
import org.elasticsearch.transport.BytesTransportRequest;
5254
import org.elasticsearch.transport.ClusterConnectionManager;
5355
import org.elasticsearch.transport.ConnectTransportException;
5456
import org.elasticsearch.transport.ConnectionProfile;
@@ -584,8 +586,13 @@ public void sendRequest(
584586
// poor mans request cloning...
585587
BytesStreamOutput bStream = new BytesStreamOutput();
586588
request.writeTo(bStream);
587-
RequestHandlerRegistry<?> reg = MockTransportService.this.getRequestHandler(action);
588-
final TransportRequest clonedRequest = reg.newRequest(bStream.bytes().streamInput());
589+
final TransportRequest clonedRequest;
590+
if (request instanceof BytesTransportRequest) {
591+
clonedRequest = copyRawBytesForBwC(bStream);
592+
} else {
593+
RequestHandlerRegistry<?> reg = MockTransportService.this.getRequestHandler(action);
594+
clonedRequest = reg.newRequest(bStream.bytes().streamInput());
595+
}
589596
assert clonedRequest.getClass().equals(MasterNodeRequestHelper.unwrapTermOverride(request).getClass())
590597
: clonedRequest + " vs " + request;
591598

@@ -633,6 +640,15 @@ protected void doRun() throws IOException {
633640
}
634641
}
635642

643+
// Some request handlers read back a BytesTransportRequest
644+
// into a different class that cannot be re-serialized (i.e. JOIN_VALIDATE_ACTION_NAME),
645+
// in those cases we just copy the raw bytes back to a BytesTransportRequest.
646+
// This is only needed for the BwC for JOIN_VALIDATE_ACTION_NAME and can be removed in the next major
647+
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION)
648+
private static TransportRequest copyRawBytesForBwC(BytesStreamOutput bStream) throws IOException {
649+
return new BytesTransportRequest(bStream.bytes().streamInput());
650+
}
651+
636652
@Override
637653
public void clearCallback() {
638654
synchronized (this) {

0 commit comments

Comments
 (0)