dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] rangtao commented on issue #2435: Summary of several issues of graceful shutdown
Date Mon, 17 Sep 2018 01:42:55 GMT
rangtao commented on issue #2435: Summary of several issues of graceful shutdown
URL: https://github.com/apache/incubator-dubbo/issues/2435#issuecomment-421870090
 
 
   1. 我同意您的说法,Dubbo容器不局限于Spring,可能我描述不太好,目前我们实际应用中使用的容器就是Spring。
   2. 确实您没有正面回答我的问题,那么我描述下2.6.3版本停机在如下场景下存在问题:如果应用程序通过停机hook触发,DubboShutDown
Hook会调用destroyAll方法,因为容器(比如Spring)也通过Hook停机,此时Spirng会提前关闭,可能导致dubbo方法内部无法获取业务Bean。因为多个hook的执行的无序性,destroyAll方法第二次执行会立即返回,所以可能导致容器先摧毁。
   3. 关于第三个问题,在2.6.1中ProtocolConfig类中,destroyAll方法包含如下sleep代码。2.6.2中将此部分sleep代码删除了。
   2.6.1:
   public static void destroyAll() {
           if (!destroyed.compareAndSet(false, true)) {
               return;
           }
           AbstractRegistryFactory.destroyAll();
   
           // Wait for registry notification
           try {
               **Thread.sleep(ConfigUtils.getServerShutdownTimeout());**
           } catch (InterruptedException e) {
               logger.warn("Interrupted unexpectedly when waiting for registry notification
during shutdown process!");
           }
   
           ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
           for (String protocolName : loader.getLoadedExtensions()) {
               try {
                   Protocol protocol = loader.getLoadedExtension(protocolName);
                   if (protocol != null) {
                       protocol.destroy();
                   }
               } catch (Throwable t) {
                   logger.warn(t.getMessage(), t);
               }
           }
       }
   2.6.2:
       // TODO: 2017/8/30 to move this method somewhere else
       public static void destroyAll() {
           if (!destroyed.compareAndSet(false, true)) {
               return;
           }
   
           AbstractRegistryFactory.destroyAll();
   
           ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
           for (String protocolName : loader.getLoadedExtensions()) {
               try {
                   Protocol protocol = loader.getLoadedExtension(protocolName);
                   if (protocol != null) {
                       protocol.destroy();
                   }
               } catch (Throwable t) {
                   logger.warn(t.getMessage(), t);
               }
           }
       }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Mime
View raw message