-
Notifications
You must be signed in to change notification settings - Fork 4k
[STORM-2754] Not killing on exceptions in other threads #2341
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -534,29 +534,43 @@ public static boolean isZkAuthenticationConfiguredTopology(Map<String, Object> c | |
| && !((String)conf.get(Config.STORM_ZOOKEEPER_TOPOLOGY_AUTH_SCHEME)).isEmpty()); | ||
| } | ||
|
|
||
| public static void handleUncaughtException(Throwable t) { | ||
| handleUncaughtException(t, defaultAllowedExceptions); | ||
| public static void handleUncaughtExceptionWithoutKillingProcess(Throwable t) { | ||
| handleUncaughtException(t, defaultAllowedExceptions, true); | ||
| } | ||
|
|
||
| public static void handleUncaughtException(Throwable t, Set<Class> allowedExceptions) { | ||
| handleUncaughtException(t, allowedExceptions, false); | ||
| } | ||
|
|
||
| public static void handleUncaughtException(Throwable t) { | ||
| handleUncaughtException(t, defaultAllowedExceptions, false); | ||
| } | ||
|
|
||
| public static void handleUncaughtException(Throwable t, Set<Class> allowedExceptions, Boolean alwaysSwallow) { | ||
| if (t != null) { | ||
| if (t instanceof OutOfMemoryError) { | ||
| try { | ||
| System.err.println("Halting due to Out Of Memory Error..." + Thread.currentThread().getName()); | ||
| } catch (Throwable err) { | ||
| //Again we don't want to exit because of logging issues. | ||
| if (t instanceof Error) { | ||
| if (t instanceof OutOfMemoryError) { | ||
| try { | ||
| System.err.println("Halting due to Out Of Memory Error..." + Thread.currentThread().getName()); | ||
| } catch (Throwable err) { | ||
| //Again we don't want to exit because of logging issues. | ||
| } | ||
| Runtime.getRuntime().halt(-1); | ||
| } else { | ||
| LOG.info("Bubble up the Error {} {}", t.getClass(), t); | ||
| throw new Error(t); | ||
| } | ||
| Runtime.getRuntime().halt(-1); | ||
| } | ||
| } | ||
|
|
||
| if(allowedExceptions.contains(t.getClass())) { | ||
| LOG.info("Swallowing {} {}", t.getClass(), t); | ||
| return; | ||
| } | ||
| if(alwaysSwallow || allowedExceptions.contains(t.getClass())) { | ||
| LOG.info("Swallowing {} {}", t.getClass(), t); | ||
| return; | ||
| } | ||
|
|
||
| //Running in daemon mode, we would pass Error to calling thread. | ||
| throw new Error(t); | ||
| //Running in daemon mode, we would pass Error to calling thread. | ||
| LOG.info("Bubble up the Error {} {}", t.getClass(), t); | ||
| throw new Error(t); | ||
| } | ||
| } | ||
|
|
||
| public static byte[] thriftSerialize(TBase t) { | ||
|
|
@@ -865,7 +879,7 @@ public static void setupDefaultUncaughtExceptionHandler() { | |
| Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
| public void uncaughtException(Thread thread, Throwable thrown) { | ||
| try { | ||
| handleUncaughtException(thrown); | ||
| handleUncaughtExceptionWithoutKillingProcess(thrown); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will swallow all the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question, if a thread gets an exception and the process is not shut down, will the thread be replaced? |
||
| } catch (Error err) { | ||
| LOG.error("Received error in main thread.. terminating server...", err); | ||
| Runtime.getRuntime().exit(-2); | ||
|
|
||
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.
If a thread hits the exception handler will it still die? If so who is responsible for replacing it? As far as I can tell this handler is used by a HashedWheelTimer in Context, and it doesn't look to me like that class will replace a dead thread.
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.
It looks like the HashedWheelTimer will not be replaced - I'll take a second pass at this to confirm