From d338eb72d40ecf4da66531aa0e9c4eba347b858e Mon Sep 17 00:00:00 2001 From: Mary Gouseti Date: Mon, 3 Nov 2025 10:52:57 +0200 Subject: [PATCH] Add logging so we can time the downsampling action (#137496) We suspect that https://github.com/elastic/elasticsearch/issues/137148 is caused by a legit timeout and not that it failed to notify the listener. In order to verify that we added some extra logging lines that allow us to better track the time. More details in https://github.com/elastic/elasticsearch/issues/137148#issuecomment-3467489655 (cherry picked from commit 9770442d77ceac0dda6f6e6a07d0d386885ab52a) # Conflicts: # x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java --- .../downsample/DownsampleTransportFailureIT.java | 6 ++++++ .../xpack/downsample/TransportDownsampleAction.java | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleTransportFailureIT.java b/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleTransportFailureIT.java index d8b27cd52724b..aad133bb3f88f 100644 --- a/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleTransportFailureIT.java +++ b/x-pack/plugin/downsample/src/internalClusterTest/java/org/elasticsearch/xpack/downsample/DownsampleTransportFailureIT.java @@ -30,6 +30,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.InternalTestCluster; +import org.elasticsearch.test.junit.annotations.TestIssueLogging; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentFactory; @@ -263,6 +264,10 @@ private void assertIndexDoesNotExist(final String nodeName, final String indexNa assertEquals("no such index [" + indexName + "]", targetIndexNotFoundException.getMessage()); } + @TestIssueLogging( + value = "org.elasticsearch.xpack.downsample.TransportDownsampleAction:DEBUG", + issueUrl = "https://github.com/elastic/elasticsearch/issues/137148" + ) public void testNoDisruption() { // GIVEN @@ -277,6 +282,7 @@ public void testNoDisruption() { // WHEN nothing happens // THEN + logger.info("Executing downsample action from [{}] to [{}]", SOURCE_INDEX_NAME, TARGET_INDEX_NAME); final AcknowledgedResponse downsampleResponse = testCluster.masterClient() .execute(DownsampleAction.INSTANCE, downsampleRequest) .actionGet(TimeValue.timeValueMillis(DOWNSAMPLE_ACTION_TIMEOUT_MILLIS)); diff --git a/x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java b/x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java index 9342a62cb849c..4039a5bf526f3 100644 --- a/x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java +++ b/x-pack/plugin/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java @@ -238,6 +238,11 @@ protected void masterOperation( ClusterState state, ActionListener listener ) { + logger.debug( + "Starting downsampling [{}] with [{}] interval", + request.getSourceIndex(), + request.getDownsampleConfig().getFixedInterval() + ); long startTime = nowSupplier.get(); String sourceIndexName = request.getSourceIndex(); IndexNameExpressionResolver.assertExpressionHasNullOrDataSelector(sourceIndexName); @@ -1019,6 +1024,7 @@ private void createDownsampleIndex( taskQueue.submitTask("create-downsample-index [" + downsampleIndexName + "]", new DownsampleClusterStateUpdateTask(listener) { @Override public ClusterState execute(ClusterState currentState) throws Exception { + logger.debug("Creating downsample index [{}]", downsampleIndexName); return metadataCreateIndexService.applyCreateIndexRequest( currentState, createIndexClusterStateUpdateRequest, @@ -1083,6 +1089,7 @@ class UpdateDownsampleIndexSettingsActionListener implements ActionListener { @Override public void onResponse(final AcknowledgedResponse response) { + logger.debug("Preparing to force merge downsample index [{}]", downsampleIndexName); ForceMergeRequest request = new ForceMergeRequest(downsampleIndexName); request.maxNumSegments(1); request.setParentTask(parentTask); @@ -1245,12 +1254,14 @@ class MeasurementActionListener implements ActionListener @Override public void onResponse(final AcknowledgedResponse response) { recordSuccessMetrics(startTime); + logger.debug("Downsampling measured successfully"); actionListener.onResponse(AcknowledgedResponse.TRUE); } @Override public void onFailure(Exception e) { recordSuccessMetrics(startTime); + logger.debug("Downsampling measured successfully", e); this.actionListener.onFailure(e); }