Code Monkey home page Code Monkey logo

Comments (11)

XiaochunLU avatar XiaochunLU commented on June 13, 2024 5

工作流程上要求自动部署,现在引入dubbo后,tomcat重新部署某个应用就hang在那边了,流程走不下去。Dubbox发现provider可以正常关闭,但是consumer死活无法关闭,究其原因是NettyClient里面ShutdownHook没有执行到。我们用了一个比较hack的方法,通过反射来调用NettyClient#channelFactory.releaseExternalResources()

        try {
            final Class<?> clazz = Class.forName("com.alibaba.dubbo.remoting.transport.netty.NettyClient");
            Field field = clazz.getDeclaredField("channelFactory");
            field.setAccessible(true);
            Object channelFactory = field.get(null);
            Method method = channelFactory.getClass().getMethod("releaseExternalResources");
            method.invoke(channelFactory);
        } catch (Exception e){
            e.printStackTrace();
        }

from dubbox.

mauersu avatar mauersu commented on June 13, 2024 2

kill -9 大家都这么追求完美吗?

from dubbox.

li-shen avatar li-shen commented on June 13, 2024

关不掉可以试试用最新snapshot。如果是强行关机,threadlocal没有释放也没什么,正常调用应该有释放程序

from dubbox.

li-shen avatar li-shen commented on June 13, 2024

关不掉可以试试用最新snapshot。如果是强行关机,threadlocal没有释放也没什么,正常调用应该有释放程序

from dubbox.

ulfsar avatar ulfsar commented on June 13, 2024

@XiaochunLU
直接release,channelFactory.如果有正在进行的任务,会有怎样的结果?

from dubbox.

tanbw avatar tanbw commented on June 13, 2024

我们在linux服务器上做并发测试时也发现了这个问题,总是有n个消费端和服务端的进程无法关闭,导致下次启动失败
我们在配置了客户端init=true(启动容器时初始化消费端)以后没这个问题了,你们也可以试试

from dubbox.

duoduobabi avatar duoduobabi commented on June 13, 2024

我也遇到了你这个问题。我跟踪了下,消费端一直没有在ZooKeeper注册中心注销。你看下你的ZooKeeper版本是不是3.3.3。你把ZooKeeper版本换成3.4.5试一试。zkclient0.1间接依赖的ZooKeeper版本是3.3.3。

from dubbox.

StonyShi avatar StonyShi commented on June 13, 2024

public class WebContextListener implements ApplicationListener {
private static final Logger logger = LoggerFactory.getLogger(WebContextListener.class);

@Override
public void onApplicationEvent(ApplicationEvent applicationEvent) {
    if (applicationEvent instanceof ContextStartedEvent){
        logger.debug("It was Started.");
    }

    if (applicationEvent instanceof ContextClosedEvent){
        ContextClosedEvent event = (ContextClosedEvent) applicationEvent;
        if(event.getApplicationContext().getParent()==null){
            logger.debug("App context was Closed.");
            synchronized (Main.class) {
                try {
                    Main.class.notifyAll();
                } catch (Throwable e) {}
            }
            Runtime.getRuntime().exit(0);
        }else{
            logger.debug("Web context was Closed.");
        }
        event = null;
    }
}

}

from dubbox.

StonyShi avatar StonyShi commented on June 13, 2024

用一个监听ContextClosed 方法来关闭

from dubbox.

barbedarhl avatar barbedarhl commented on June 13, 2024

我也遇到这个问题了,查了jstack发现除了主线程之外还有一个非daemon线程。

"Hashed wheel timer #1@4029" prio=5 tid=0x32 nid=NA sleeping
  java.lang.Thread.State: TIMED_WAITING
      at java.lang.Thread.sleep(Thread.java:-1)
      at org.jboss.netty.util.HashedWheelTimer$Worker.waitForNextTick(HashedWheelTimer.java:503)
      at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:401)
      at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
      at java.lang.Thread.run(Thread.java:745)

我现在尝试去解决一下这个问题。待会把解决方法po出来

from dubbox.

barbedarhl avatar barbedarhl commented on June 13, 2024

刚才发现这个Hashed wheel timer使用的是Executors.DefaultThreadFactory.newThread创建的,所以是non-daemon。所以导致了tomcat主进程无法终止。#117

from dubbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.