You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by kishorvpatil <gi...@git.apache.org> on 2015/06/18 07:44:27 UTC

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

GitHub user kishorvpatil opened a pull request:

    https://github.com/apache/storm/pull/597

    [STORM-874] Add UncaughtExceptionHandler for netty threads

    The netty threads need to handle uncaught exceptions. This would help ensure that JVM exits if netty threads hit OOM Error  while allocating new buffer.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kishorvpatil/incubator-storm storm874

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/storm/pull/597.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #597
    
----
commit 6c4f8bf61fd5a4b86fc6df1bf33a2a90f5f5797e
Author: Kishor Patil <kp...@yahoo-inc.com>
Date:   2015-06-17T21:15:51Z

    Add UncaughtExceptionHandler for netty threads as it should for JVM halt in case or OOM Error

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by d2r <gi...@git.apache.org>.
Github user d2r commented on a diff in the pull request:

    https://github.com/apache/storm/pull/597#discussion_r43150246
  
    --- Diff: storm-core/src/jvm/backtype/storm/messaging/netty/NettyUncaughtExceptionHandler.java ---
    @@ -0,0 +1,35 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package backtype.storm.messaging.netty;
    +
    +import backtype.storm.utils.Utils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +public class NettyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
    +  private static final Logger LOG = LoggerFactory.getLogger(NettyUncaughtExceptionHandler.class);
    +  @Override
    +  public void uncaughtException(Thread t, Throwable e) {
    +    try {
    +      Utils.handleUncaughtException(e);
    --- End diff --
    
    I agree with @HeartSaVioR , we should at least log any (unchecked) Exception instead of swallow it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the pull request:

    https://github.com/apache/storm/pull/597#issuecomment-134759973
  
    @eshioji We are catching `Error` not `RunTimeException` which shows more of a JVM  resource issue - hence we do exit from the JVM - its more serious than just considering some service being down.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the pull request:

    https://github.com/apache/storm/pull/597#issuecomment-134761846
  
    @harshach Sorry for so long in responding to it. The `Utils.handleUncaughtException` writes ot STDOUT to avoid further major exception by attempting to log exceptions. But otherwise we log them. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by d2r <gi...@git.apache.org>.
Github user d2r commented on a diff in the pull request:

    https://github.com/apache/storm/pull/597#discussion_r43150822
  
    --- Diff: storm-core/src/jvm/backtype/storm/messaging/netty/NettyUncaughtExceptionHandler.java ---
    @@ -0,0 +1,35 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package backtype.storm.messaging.netty;
    +
    +import backtype.storm.utils.Utils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +public class NettyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
    +  private static final Logger LOG = LoggerFactory.getLogger(NettyUncaughtExceptionHandler.class);
    +  @Override
    +  public void uncaughtException(Thread t, Throwable e) {
    +    try {
    +      Utils.handleUncaughtException(e);
    --- End diff --
    
    Also, the name Utils/handleUncaughtException here implies we are handling exceptions that could not be otherwise be dealt with, and so this is the end of the road.  It does not seem that we should return from this handler expecting some other code to deal with the situation, but we should bring down the JVM or throw.  If the code is not intended to be used this way, then we should rename and/or document what is expected of the caller to do with `t` after we return.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by HeartSaVioR <gi...@git.apache.org>.
Github user HeartSaVioR commented on a diff in the pull request:

    https://github.com/apache/storm/pull/597#discussion_r33100021
  
    --- Diff: storm-core/src/jvm/backtype/storm/messaging/netty/NettyUncaughtExceptionHandler.java ---
    @@ -0,0 +1,35 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package backtype.storm.messaging.netty;
    +
    +import backtype.storm.utils.Utils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +public class NettyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
    +  private static final Logger LOG = LoggerFactory.getLogger(NettyUncaughtExceptionHandler.class);
    +  @Override
    +  public void uncaughtException(Thread t, Throwable e) {
    +    try {
    +      Utils.handleUncaughtException(e);
    --- End diff --
    
    @kishorvpatil 
    Utils.handleUncaughtException() only takes care of Error, and any kinds of Exception will be silently ignored without leaving any logs. 
    Is it intentional? Or do we need to take care?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/storm/pull/597#discussion_r37927420
  
    --- Diff: storm-core/src/jvm/backtype/storm/messaging/netty/NettyUncaughtExceptionHandler.java ---
    @@ -0,0 +1,35 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package backtype.storm.messaging.netty;
    +
    +import backtype.storm.utils.Utils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +public class NettyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
    +  private static final Logger LOG = LoggerFactory.getLogger(NettyUncaughtExceptionHandler.class);
    +  @Override
    +  public void uncaughtException(Thread t, Throwable e) {
    +    try {
    +      Utils.handleUncaughtException(e);
    --- End diff --
    
    @HeartSaVioR  We consider the Netty message handlers should take care of all those exceptions. We leave JVM level Error to be handled at executorservice handler level.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil closed the pull request at:

    https://github.com/apache/storm/pull/597


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the pull request:

    https://github.com/apache/storm/pull/597#issuecomment-160759703
  
    These changes went in as part of #838. So closing the PR and JIRA


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by eshioji <gi...@git.apache.org>.
Github user eshioji commented on the pull request:

    https://github.com/apache/storm/pull/597#issuecomment-120603640
  
    If the thread is used in `ThreadPoolExecutor` (like the boss & worker thread pool currently used), `UncaughtExceptionHandler` are not invoked because `ThreadPoolExecutor` suppress uncaught exceptions coming from tasks (see e.g. http://stackoverflow.com/questions/1838923/why-is-uncaughtexceptionhandler-not-called-by-executorservice). There are workarounds but they are quite hacky.
    
    Maybe it makes more sense to consider the service unhealthy if messages are unable to be dispatched, rather than based on whether an uncaught exception was encountered?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request: [STORM-874] Add UncaughtExceptionHandler for n...

Posted by harshach <gi...@git.apache.org>.
Github user harshach commented on the pull request:

    https://github.com/apache/storm/pull/597#issuecomment-113995243
  
    @kishorvpatil would it makes sense to log the exception as well? , allows users to know the cause of jvm exit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---