Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log message on slow restarts #16340

Merged
merged 2 commits into from Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -125,7 +125,7 @@ public void accept(Integer integer) {
//we need to set this here, while we still have the correct TCCL
//this is so the config is still valid, and we can read HTTP config from application.properties
log.info(
"Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure");
"Attempting to start live reload endpoint to recover from previous Quarkus startup failure");
if (RuntimeUpdatesProcessor.INSTANCE != null) {
Thread.currentThread().setContextClassLoader(curatedApplication.getBaseRuntimeClassLoader());
try {
Expand Down
Expand Up @@ -31,6 +31,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
Expand Down Expand Up @@ -82,6 +83,8 @@ public class RuntimeUpdatesProcessor implements HotReplacementContext, Closeable
*/
private volatile boolean firstScanDone = false;

private static volatile boolean instrumentationLogPrinted = false;

private final Map<Path, Long> sourceFileTimestamps = new ConcurrentHashMap<>();
private final Map<Path, Long> watchedFileTimestamps = new ConcurrentHashMap<>();
private final Map<Path, Long> classFileChangeTimeStamps = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -255,7 +258,16 @@ public boolean doScan(boolean userInitiated) throws IOException {
|| (IsolatedDevModeMain.deploymentProblem != null && userInitiated) || configFileRestartNeeded);
if (restartNeeded) {
restartCallback.accept(filesChanged, changedClassResults);
log.infof("Hot replace total time: %ss ", Timing.convertToBigDecimalSeconds(System.nanoTime() - startNanoseconds));
long timeNanoSeconds = System.nanoTime() - startNanoseconds;
log.infof("Live reload total time: %ss ", Timing.convertToBigDecimalSeconds(timeNanoSeconds));
if (TimeUnit.SECONDS.convert(timeNanoSeconds, TimeUnit.NANOSECONDS) >= 4 && !instrumentationEnabled()) {
if (!instrumentationLogPrinted) {
instrumentationLogPrinted = true;
log.info(
"Live reload took more than 4 seconds, you may want to enable instrumentation based reload (quarkus.live-reload.instrumentation=true). This allows small changes to take effect without restarting Quarkus.");
}
}

return true;
} else if (!filesChanged.isEmpty()) {
for (Consumer<Set<String>> consumer : noRestartChangesConsumers) {
Expand All @@ -268,7 +280,7 @@ public boolean doScan(boolean userInitiated) throws IOException {
log.infof("Files changed but restart not needed - notified extensions in: %ss ",
Timing.convertToBigDecimalSeconds(System.nanoTime() - startNanoseconds));
} else if (instrumentationChange) {
log.infof("Hot replace performed via instrumentation, no restart needed, total time: %ss ",
log.infof("Live reload performed via instrumentation, no restart needed, total time: %ss ",
Timing.convertToBigDecimalSeconds(System.nanoTime() - startNanoseconds));
}
return false;
Expand Down
Expand Up @@ -178,7 +178,7 @@ public static void startServerAfterFailedStart() {
//we shut it down in this case, as we have no idea what state it is in
final Handler<RoutingContext> prevHotReplacementHandler = hotReplacementHandler;
shutDownDevMode();
// reset back to the older hot replacement handler, so that it can be used
// reset back to the older live reload handler, so that it can be used
// to watch any artifacts that need hot deployment to fix the reason which caused
// the server start to fail
hotReplacementHandler = prevHotReplacementHandler;
Expand Down
Expand Up @@ -233,7 +233,7 @@ public void handle(Buffer buffer) {
}).exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable error) {
log.error("Failed writing hot replacement data", error);
log.error("Failed writing live reload data", error);
event.response().setStatusCode(500);
event.response().end();
}
Expand Down
Expand Up @@ -61,7 +61,7 @@ public void handle(Promise<Boolean> event) {
try {
restart = hotReplacementContext.doScan(true);
} catch (Exception e) {
event.fail(new IllegalStateException("Unable to perform hot replacement scanning", e));
event.fail(new IllegalStateException("Unable to perform live reload scanning", e));
return;
}
}
Expand Down