-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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][common] Fix issue where logs get truncated when Runtime.halt is used to terminate the process #17589
Conversation
…gets terminated with Runtime.halt - call Log4j2's LogManager.shutdown before terminating the process with Runtime.halt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pulsar-common/src/main/java/org/apache/pulsar/common/util/ShutdownUtil.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @merlimat's comment. Otherwise, LGTM.
@michaeljmarshall @merlimat I addressed the review feedback. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@lhotari
|
log.warn("Triggering immediate shutdown of current process with status {}", status, | ||
new Exception("Stacktrace for immediate shutdown")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lhotari recently I found that this warning can be annoying or misleading. Said if we run a command ./bin/pulsar-admin schemas delete
so that it gives the usage info. The user will found:
$ ./bin/pulsar-admin schemas delete
Main parameters are required ("persistent://tenant/namespace/topic")
Delete the latest schema for a topic
Usage: delete [options] persistent://tenant/namespace/topic
Options:
-f, --force
whether to delete schema completely. If true, delete all resources
(including metastore and ledger), otherwise only do a mark deletion and
not remove any resources indeed
Default: false
2022-12-09T15:39:22,850+0800 [main] WARN org.apache.pulsar.common.util.ShutdownUtil - Triggering immediate shutdown of current process with status 1
java.lang.Exception: Stacktrace for immediate shutdown
at org.apache.pulsar.common.util.ShutdownUtil.triggerImmediateForcefulShutdown(ShutdownUtil.java:52) ~[pulsar-common.jar:2.11.0-SNAPSHOT]
at org.apache.pulsar.admin.cli.PulsarAdminTool.exit(PulsarAdminTool.java:309) ~[pulsar-client-tools.jar:2.11.0-SNAPSHOT]
at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:300) ~[pulsar-client-tools.jar:2.11.0-SNAPSHOT]
and confused.
Perhaps we remove this logging line or change it to debug
level?
Fixes #17587
Motivation
Pulsar log file might not contain the last few log lines when the Pulsar process is abnormally terminated with Runtime.halt.
Modifications
ShutdownUtil.triggerImmediateForcefulShutdown
which calls Log4j2's LogManager.shutdown before terminating the process with Runtime.haltRuntime.halt
withShutdownUtil.triggerImmediateForcefulShutdown
in the Pulsar code baseDocumentation
doc-required
(Your PR needs to update docs and you will update later)
doc-not-needed
(Please explain why)
doc
(Your PR contains doc changes)
doc-complete
(Docs have been already added)