Skip to content

Commit 43a9e6f

Browse files
authored
Add extra logging to testChildrenTasksCancelledOnTimeout (#128888)
Relates #123568
1 parent e23a5e7 commit 43a9e6f

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ tests:
204204
- class: org.elasticsearch.packaging.test.DockerTests
205205
method: test151MachineDependentHeapWithSizeOverride
206206
issue: https://github.com/elastic/elasticsearch/issues/123437
207-
- class: org.elasticsearch.action.admin.cluster.node.tasks.CancellableTasksIT
208-
method: testChildrenTasksCancelledOnTimeout
209-
issue: https://github.com/elastic/elasticsearch/issues/123568
210207
- class: org.elasticsearch.xpack.searchablesnapshots.FrozenSearchableSnapshotsIntegTests
211208
method: testCreateAndRestorePartialSearchableSnapshot
212209
issue: https://github.com/elastic/elasticsearch/issues/123773

server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.action.ActionRequestValidationException;
1818
import org.elasticsearch.action.ActionResponse;
1919
import org.elasticsearch.action.ActionType;
20+
import org.elasticsearch.action.DelegatingActionListener;
2021
import org.elasticsearch.action.LatchedActionListener;
2122
import org.elasticsearch.action.LegacyActionRequest;
2223
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
@@ -26,6 +27,7 @@
2627
import org.elasticsearch.action.support.PlainActionFuture;
2728
import org.elasticsearch.client.internal.node.NodeClient;
2829
import org.elasticsearch.cluster.node.DiscoveryNode;
30+
import org.elasticsearch.common.Strings;
2931
import org.elasticsearch.common.io.stream.StreamInput;
3032
import org.elasticsearch.common.io.stream.StreamOutput;
3133
import org.elasticsearch.common.util.CollectionUtils;
@@ -34,6 +36,8 @@
3436
import org.elasticsearch.common.util.set.Sets;
3537
import org.elasticsearch.core.TimeValue;
3638
import org.elasticsearch.injection.guice.Inject;
39+
import org.elasticsearch.logging.LogManager;
40+
import org.elasticsearch.logging.Logger;
3741
import org.elasticsearch.plugins.ActionPlugin;
3842
import org.elasticsearch.plugins.Plugin;
3943
import org.elasticsearch.tasks.CancellableTask;
@@ -43,6 +47,7 @@
4347
import org.elasticsearch.tasks.TaskInfo;
4448
import org.elasticsearch.tasks.TaskManager;
4549
import org.elasticsearch.test.ESIntegTestCase;
50+
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
4651
import org.elasticsearch.threadpool.ThreadPool;
4752
import org.elasticsearch.transport.ReceiveTimeoutTransportException;
4853
import org.elasticsearch.transport.SendRequestTransportException;
@@ -74,6 +79,9 @@
7479
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
7580
public class CancellableTasksIT extends ESIntegTestCase {
7681

82+
// Temporary addition for investigation into https://github.com/elastic/elasticsearch/issues/123568
83+
private static final Logger logger = LogManager.getLogger(CancellableTasksIT.class);
84+
7785
static int idGenerator = 0;
7886
static final Map<TestRequest, CountDownLatch> beforeSendLatches = ConcurrentCollections.newConcurrentMap();
7987
static final Map<TestRequest, CountDownLatch> arrivedLatches = ConcurrentCollections.newConcurrentMap();
@@ -366,18 +374,42 @@ public void testRemoveBanParentsOnDisconnect() throws Exception {
366374
}
367375
}
368376

377+
@TestIssueLogging(
378+
issueUrl = "https://github.com/elastic/elasticsearch/issues/123568",
379+
value = "org.elasticsearch.transport.TransportService.tracer:TRACE"
380+
+ ",org.elasticsearch.tasks.TaskManager:TRACE"
381+
+ ",org.elasticsearch.action.admin.cluster.node.tasks.CancellableTasksIT:DEBUG"
382+
)
369383
public void testChildrenTasksCancelledOnTimeout() throws Exception {
370384
Set<DiscoveryNode> nodes = clusterService().state().nodes().stream().collect(Collectors.toSet());
371385
final TestRequest rootRequest = generateTestRequest(nodes, 0, between(1, 4), true);
386+
logger.info("generated request\n{}", buildTestRequestDescription(rootRequest, "", new StringBuilder()).toString());
372387
ActionFuture<TestResponse> rootTaskFuture = client().execute(TransportTestAction.ACTION, rootRequest);
388+
logger.info("action executed");
373389
allowEntireRequest(rootRequest);
390+
logger.info("execution released");
374391
waitForRootTask(rootTaskFuture, true);
392+
logger.info("root task completed");
375393
ensureBansAndCancellationsConsistency();
394+
logger.info("ensureBansAndCancellationsConsistency completed");
376395

377396
// Make sure all descendent requests have completed
378397
for (TestRequest subRequest : rootRequest.descendants()) {
398+
logger.info("awaiting completion of request {}", subRequest.getDescription());
379399
safeAwait(completedLatches.get(subRequest));
380400
}
401+
logger.info("all requests completed");
402+
}
403+
404+
// Temporary addition for investigation into https://github.com/elastic/elasticsearch/issues/123568
405+
static StringBuilder buildTestRequestDescription(TestRequest request, String prefix, StringBuilder stringBuilder) {
406+
stringBuilder.append(prefix)
407+
.append(Strings.format("id=%d [timeout=%s] %s", request.id, request.timeout, request.node.descriptionWithoutAttributes()))
408+
.append('\n');
409+
for (TestRequest subRequest : request.subRequests) {
410+
buildTestRequestDescription(subRequest, prefix + " ", stringBuilder);
411+
}
412+
return stringBuilder;
381413
}
382414

383415
static TaskId getRootTaskId(TestRequest request) throws Exception {
@@ -506,6 +538,8 @@ public void writeTo(StreamOutput out) throws IOException {
506538

507539
public static class TransportTestAction extends HandledTransportAction<TestRequest, TestResponse> {
508540

541+
private static final Logger logger = CancellableTasksIT.logger;
542+
509543
public static ActionType<TestResponse> ACTION = new ActionType<>("internal::test_action");
510544
private final TransportService transportService;
511545
private final NodeClient client;
@@ -565,7 +599,22 @@ protected void doExecute(Task task, TestRequest request, ActionListener<TestResp
565599
protected void startSubTask(TaskId parentTaskId, TestRequest subRequest, ActionListener<TestResponse> listener) {
566600
subRequest.setParentTask(parentTaskId);
567601
CountDownLatch completeLatch = completedLatches.get(subRequest);
568-
LatchedActionListener<TestResponse> latchedListener = new LatchedActionListener<>(listener, completeLatch);
602+
ActionListener<TestResponse> latchedListener = new DelegatingActionListener<>(
603+
new LatchedActionListener<>(listener, completeLatch)
604+
) {
605+
// Temporary logging addition for investigation into https://github.com/elastic/elasticsearch/issues/123568
606+
@Override
607+
public void onResponse(TestResponse testResponse) {
608+
logger.debug("processing successful response to request [{}]", subRequest.getDescription());
609+
delegate.onResponse(testResponse);
610+
}
611+
612+
@Override
613+
public void onFailure(Exception e) {
614+
logger.debug("processing exceptional response to request [{}]: {}", subRequest.getDescription(), e.getMessage());
615+
super.onFailure(e);
616+
}
617+
};
569618
transportService.getThreadPool().generic().execute(new AbstractRunnable() {
570619
@Override
571620
public void onFailure(Exception e) {
@@ -596,6 +645,13 @@ protected void doRun() throws Exception {
596645
TransportResponseHandler.TRANSPORT_WORKER
597646
)
598647
);
648+
// Temporary addition for investigation into https://github.com/elastic/elasticsearch/issues/123568
649+
logger.debug(
650+
"sent test request [{}] from [{}] to [{}]",
651+
subRequest.getDescription(),
652+
client.getLocalNodeId(),
653+
subRequest.node.descriptionWithoutAttributes()
654+
);
599655
}
600656
}
601657
});

0 commit comments

Comments
 (0)