Skip to content

Commit 2c1eab2

Browse files
authored
Clarify slow cluster-state log messages (#38302)
The message `... took [31s] above the warn threshold of 30s` suggests incorrectly that the task took 61 seconds. This commit adds the clarifying words `which is`.
1 parent ac07386 commit 2c1eab2

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public void onSuccess(String source) {
517517

518518
protected void warnAboutSlowTaskIfNeeded(TimeValue executionTime, String source) {
519519
if (executionTime.getMillis() > slowTaskLoggingThreshold.getMillis()) {
520-
logger.warn("cluster state applier task [{}] took [{}] above the warn threshold of {}", source, executionTime,
520+
logger.warn("cluster state applier task [{}] took [{}] which is above the warn threshold of {}", source, executionTime,
521521
slowTaskLoggingThreshold);
522522
}
523523
}

server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.elasticsearch.cluster.service;
2121

22-
import org.apache.logging.log4j.LogManager;
23-
import org.apache.logging.log4j.Logger;
2422
import org.elasticsearch.cluster.ClusterName;
2523
import org.elasticsearch.cluster.ClusterState;
2624
import org.elasticsearch.cluster.ClusterStateApplier;
@@ -45,8 +43,6 @@
4543
import java.util.Map;
4644

4745
public class ClusterService extends AbstractLifecycleComponent {
48-
private static final Logger logger = LogManager.getLogger(ClusterService.class);
49-
5046
private final MasterService masterService;
5147

5248
private final ClusterApplierService clusterApplierService;

server/src/main/java/org/elasticsearch/cluster/service/MasterService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public TimeValue ackTimeout() {
569569

570570
protected void warnAboutSlowTaskIfNeeded(TimeValue executionTime, String source) {
571571
if (executionTime.getMillis() > slowTaskLoggingThreshold.getMillis()) {
572-
logger.warn("cluster state update task [{}] took [{}] above the warn threshold of {}", source, executionTime,
572+
logger.warn("cluster state update task [{}] took [{}] which is above the warn threshold of {}", source, executionTime,
573573
slowTaskLoggingThreshold);
574574
}
575575
}

server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,19 @@ public void testLongClusterStateUpdateLogging() throws Exception {
195195
"test1 shouldn't see because setting is too low",
196196
ClusterApplierService.class.getCanonicalName(),
197197
Level.WARN,
198-
"*cluster state applier task [test1] took [*] above the warn threshold of *"));
198+
"*cluster state applier task [test1] took [*] which is above the warn threshold of *"));
199199
mockAppender.addExpectation(
200200
new MockLogAppender.SeenEventExpectation(
201201
"test2",
202202
ClusterApplierService.class.getCanonicalName(),
203203
Level.WARN,
204-
"*cluster state applier task [test2] took [32s] above the warn threshold of *"));
204+
"*cluster state applier task [test2] took [32s] which is above the warn threshold of *"));
205205
mockAppender.addExpectation(
206206
new MockLogAppender.SeenEventExpectation(
207207
"test4",
208208
ClusterApplierService.class.getCanonicalName(),
209209
Level.WARN,
210-
"*cluster state applier task [test3] took [34s] above the warn threshold of *"));
210+
"*cluster state applier task [test3] took [34s] which is above the warn threshold of *"));
211211

212212
Logger clusterLogger = LogManager.getLogger(ClusterApplierService.class);
213213
Loggers.addAppender(clusterLogger, mockAppender);

server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,25 +652,25 @@ public void testLongClusterStateUpdateLogging() throws Exception {
652652
"test1 shouldn't see because setting is too low",
653653
MasterService.class.getCanonicalName(),
654654
Level.WARN,
655-
"*cluster state update task [test1] took [*] above the warn threshold of *"));
655+
"*cluster state update task [test1] took [*] which is above the warn threshold of *"));
656656
mockAppender.addExpectation(
657657
new MockLogAppender.SeenEventExpectation(
658658
"test2",
659659
MasterService.class.getCanonicalName(),
660660
Level.WARN,
661-
"*cluster state update task [test2] took [32s] above the warn threshold of *"));
661+
"*cluster state update task [test2] took [32s] which is above the warn threshold of *"));
662662
mockAppender.addExpectation(
663663
new MockLogAppender.SeenEventExpectation(
664664
"test3",
665665
MasterService.class.getCanonicalName(),
666666
Level.WARN,
667-
"*cluster state update task [test3] took [33s] above the warn threshold of *"));
667+
"*cluster state update task [test3] took [33s] which is above the warn threshold of *"));
668668
mockAppender.addExpectation(
669669
new MockLogAppender.SeenEventExpectation(
670670
"test4",
671671
MasterService.class.getCanonicalName(),
672672
Level.WARN,
673-
"*cluster state update task [test4] took [34s] above the warn threshold of *"));
673+
"*cluster state update task [test4] took [34s] which is above the warn threshold of *"));
674674

675675
Logger clusterLogger = LogManager.getLogger(MasterService.class);
676676
Loggers.addAppender(clusterLogger, mockAppender);

0 commit comments

Comments
 (0)