Coder Social home page Coder Social logo

Comments (11)

yungoo avatar yungoo commented on June 17, 2024 1

对问题2,我发现在spring的war使用
`
@configuration
public class DubboConfig {

@PreDestroy
public void shutdownDestroy() {
    ProtocolConfig.destroyAll();
}

}
`
可以避免DubboShutdownHook的异常

from dubbo.

KunkkaCoco avatar KunkkaCoco commented on June 17, 2024

我也是这种情况 。求解答

from dubbo.

bladehd avatar bladehd commented on June 17, 2024

在没使用dubbo的应用里也会有这个错误,dubbo的相关错误我理解是,tomcat已经在做class的卸载,但dubbo还在向注册中心发送注销请求,所以报错了。

from dubbo.

deepshrift avatar deepshrift commented on June 17, 2024

我也遇到相同的问题'求解答

from dubbo.

wuwen5 avatar wuwen5 commented on June 17, 2024

第一堆异常 是软件包没有优雅释放资源导致的,不影响,很多包都有这样的问题,odbc驱动包也会这样,
比如 创建了一个无法正常停止的线程,没有主动销毁,但这些都不影响,其实是可以减少的,dubbo里面有很多没有去释放的资源,参考https://github.com/alibaba/dubbo/pull/102/files。

第二堆异常是销毁顺序问题,采用shutdownhook去销毁不能保证正确的销毁顺序,我们这边目前的做法是停机前主动先去销毁dubbo的, DubboShutdownHook应该主要是提供在standalone方式运行dubbo的时候,去实现优雅停机的,但是如果是使用外部容器的方式DubboShutdownHook就不合适了,销毁应该交给容器的停止的监听去触发,否则就会出现这种顺序不对导致的问题

from dubbo.

deepshrift avatar deepshrift commented on June 17, 2024

@wuwen5 HI,朋友。第二堆异常的需要做哪些修改,能提供下具体代码吗? 如果在容器中运行dubbo,是否要禁用dubbo的DubboShutdownHook

from dubbo.

xuzunyuan avatar xuzunyuan commented on June 17, 2024

等待着高手解答

from dubbo.

lynnchae avatar lynnchae commented on June 17, 2024

@yungoo 这种在关闭tomcat时候,可以让dubbo优雅停机吗

from dubbo.

ralf0131 avatar ralf0131 commented on June 17, 2024

Related issue #1665

from dubbo.

bert82503 avatar bert82503 commented on June 17, 2024

@ralf0131 今晚我们在生产环境也遇到了作者说的第二个异常

问题描述

Dubbo应用在关闭时报NoClassDefFoundError: com/alibaba/dubbo/registry/support/SkipFailbackWrapperException
完整的异常调用栈如下:

2018-05-10 20:30:10,597 WARN  [DubboShutdownHook] c.a.d.r.z.ZookeeperRegistry - [] [] []  [DUBBO] Failed to unregister url consumer://xxx.xxx.xxx.xxx/com.wacai.ucenter.service.NicknameValidatable?application=ucenter-query&category=consumers&check=false&default.check=false&default.retries=0&default.timeout=5000&dubbo=3.1.1&init=true&interface=com.wacai.ucenter.service.NicknameValidatable&methods=queryAudit,moveNicknameCache,validateAndUid,validateAndType,validate&owner=xxx&pid=27285&revision=1.7.0&side=consumer&timestamp=1525801075589 to registry zookeeper://xxx:12181/com.alibaba.dubbo.registry.RegistryService?application=ucenter-query&backup=xxx&client=zkclient&dubbo=3.1.1&group=dubbo_product&interface=com.alibaba.dubbo.registry.RegistryService&owner=xxx&pid=27285&timestamp=1525801075625 on destroy, cause: com/alibaba/dubbo/registry/support/SkipFailbackWrapperException, dubbo version: 3.1.1, current host: xxx.xxx.xxx.xxx
java.lang.NoClassDefFoundError: com/alibaba/dubbo/registry/support/SkipFailbackWrapperException
        at com.alibaba.dubbo.registry.support.FailbackRegistry.unregister(FailbackRegistry.java:168)
        at com.alibaba.dubbo.registry.support.AbstractRegistry.destroy(AbstractRegistry.java:492)
        at com.alibaba.dubbo.registry.support.FailbackRegistry.destroy(FailbackRegistry.java:436)
        at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.destroy(ZookeeperRegistry.java:90)
        at com.alibaba.dubbo.registry.support.AbstractRegistryFactory.destroyAll(AbstractRegistryFactory.java:70)
        at com.alibaba.dubbo.config.ProtocolConfig.destroyAll(ProtocolConfig.java:429)
        at com.alibaba.dubbo.config.AbstractConfig$1.run(AbstractConfig.java:452)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.alibaba.dubbo.registry.support.SkipFailbackWrapperException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 8 common frames omitted

问题分析

根据异常日志,异常是从FailbackRegistry抛出来的,最后一个Caused by说是SkipFailbackWrapperException 类未找到,实际上类是存在的,说明是其他原因引起。
异常发生在FailbackRegistry.unregister(FailbackRegistry.java:168),和作者遇到的异常代码是同一行,对应的源代码:
failbackregistry unregister
从源代码看很清晰,FailbackRegistry.unregister(url)在执行doUnregister(url)时抛出了异常,但在执行t instanceof SkipFailbackWrapperException时又抛出了ClassNotFoundException异常,结果实际的异常被弄丢了,导致发现不了问题根源。

解决方案

t instanceof SkipFailbackWrapperException语句进行异常捕获,以便打印实际的异常日志。

            boolean skipFailback = false;
            try {
                skipFailback = t instanceof SkipFailbackWrapperException;
            } catch (Throwable t1) {
                logger.error("Failed to unregister " + url + ", waiting for retry, cause: " + t.getMessage(), t);
                logger.error("Unregister url occur unexpected error, cause: " + t1.getMessage(), t1);
            }

from dubbo.

ralf0131 avatar ralf0131 commented on June 17, 2024

This is because tomcat has been stopped but some of the threads Dubbo created did not stopped correctly.

Previously Dubbo uses ShutdownHook to stop these threads, but when tomcat is stops the web application, Dubbo's ShutdownHook has not been executed yet.

The solution is to ensure Dubbo listens to web application's lifecycle and stops the threads properly.

This issue should be fixed from 2.6.3 onwards.

from dubbo.

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.