Skip to content

Commit 6262626

Browse files
original-brownbearhenningandersen
authored andcommitted
Fix Incorrect Time Math in MockTransport (#42595) (#42617)
* Fix Incorrect Time Math in MockTransport * The timeunit here must be nanos for the current time (we even convert it accordingly in the logging) * Also, changed the log message when dumping stack traces a little to make it easier to grep for (otherwise it's the same as the message on unregister)
1 parent 001996d commit 6262626

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/framework/src/main/java/org/elasticsearch/transport/nio/MockNioTransport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,11 @@ private void maybeLogElapsedTime(long startTime) {
371371

372372
private void logLongRunningExecutions() {
373373
for (Map.Entry<Thread, Long> entry : registry.entrySet()) {
374-
final long elapsedTime = threadPool.relativeTimeInMillis() - entry.getValue();
375-
if (elapsedTime > WARN_THRESHOLD) {
374+
final long elapsedTimeInNanos = threadPool.relativeTimeInNanos() - entry.getValue();
375+
if (elapsedTimeInNanos > WARN_THRESHOLD) {
376376
final Thread thread = entry.getKey();
377-
logger.warn("Slow execution on network thread [{}] [{} milliseconds]: \n{}", thread.getName(),
378-
TimeUnit.NANOSECONDS.toMillis(elapsedTime),
377+
logger.warn("Potentially blocked execution on network thread [{}] [{} milliseconds]: \n{}", thread.getName(),
378+
TimeUnit.NANOSECONDS.toMillis(elapsedTimeInNanos),
379379
Arrays.stream(thread.getStackTrace()).map(Object::toString).collect(Collectors.joining("\n")));
380380
}
381381
}

0 commit comments

Comments
 (0)