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

Fix async log appender not print error log when bookie starting expectionally #4475

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Shutdown log before bookie exit to flush async log
AnonHxy committed Jul 28, 2024
commit 79585ff7d37063528f297a76c4b84c199f37f31b
4 changes: 4 additions & 0 deletions bookkeeper-common/pom.xml
Original file line number Diff line number Diff line change
@@ -25,6 +25,10 @@
<artifactId>bookkeeper-common</artifactId>
<name>Apache BookKeeper :: Common</name>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.bookkeeper.stats</groupId>
<artifactId>bookkeeper-stats-api</artifactId>
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.common.concurrent.FutureUtils;
import org.apache.logging.log4j.LogManager;

/**
* Utils to start components.
@@ -50,6 +51,8 @@ public void run() {
log.error("Failed to close component {} in shutdown hook gracefully, Exiting anyway",
component.getName(), e);
future.completeExceptionally(e);
} finally {
LogManager.shutdown();
}
}

@@ -75,7 +78,7 @@ public static CompletableFuture<Void> startComponent(LifecycleComponent componen
log.error("Triggered exceptionHandler of Component: {} because of Exception in Thread: {}",
component.getName(), t, e);
// start the shutdown hook when an uncaught exception happen in the lifecycle component.
shutdownHookThread.start();
FutureUtils.complete(future, null);
});

component.publishInfo(new ComponentInfoPublisher());
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.logging.log4j.LogManager;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -339,6 +340,7 @@ static int doMain(String[] args) {
server = buildAutoRecoveryServer(new BookieConfiguration(conf));
} catch (Exception e) {
LOG.error("Failed to build AutoRecovery Server", e);
LogManager.shutdown();
return ExitCode.SERVER_EXCEPTION;
}

Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.logging.log4j.LogManager;

/**
* A bookie server is a server that run bookie and serving rpc requests.
@@ -222,6 +223,7 @@ static int doMain(String[] args) {
server = buildBookieServer(new BookieConfiguration(conf));
} catch (Exception e) {
log.error("Failed to build bookie server", e);
LogManager.shutdown();
return ExitCode.SERVER_EXCEPTION;
}

Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.distributedlog.DistributedLogConfiguration;
import org.apache.logging.log4j.LogManager;

/**
* A storage server is a server that run storage service and serving rpc requests.
@@ -170,6 +171,7 @@ static int doMain(String[] args) {
grpcUseHostname);
} catch (Exception e) {
log.error("Invalid storage configuration", e);
LogManager.shutdown();
return ExitCode.INVALID_CONF.code();
}