You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/10/14 05:05:35 UTC

[GitHub] [dubbo] kylixs edited a comment on issue #8985: [3.0] RpcException/RuntimeException when Provider jvm exit

kylixs edited a comment on issue #8985:
URL: https://github.com/apache/dubbo/issues/8985#issuecomment-942943406


   Some work is done in https://github.com/apache/dubbo/pull/9033, pls check it.
   1. The application destroy processing is changed: https://github.com/apache/dubbo/pull/9033#discussion_r728613024
   2. prevent refresh metadata in application stopping. 
   ```java
           if (registered) {
               // scheduled task for updating Metadata and ServiceInstance
               asyncMetadataFuture = executorRepository.getSharedScheduledExecutor().scheduleAtFixedRate(() -> {
   
                   // ignore refresh metadata on stopping
                   if (applicationModel.isDestroyed()) {
                       return;
                   }
   
                   InMemoryWritableMetadataService localMetadataService = (InMemoryWritableMetadataService) WritableMetadataService.getDefaultExtension(applicationModel);
                   localMetadataService.blockUntilUpdated();
                   try {
                       if (!applicationModel.isDestroyed()) {
                           ServiceInstanceMetadataUtils.refreshMetadataAndInstance(serviceInstance);
                       }
                   } catch (Exception e) {
                       if (!applicationModel.isDestroyed()) {
                           logger.error("Refresh instance and metadata error", e);
                       }
                   } finally {
                       localMetadataService.releaseBlock();
                   }
               }, 0, ConfigurationUtils.get(applicationModel, METADATA_PUBLISH_DELAY_KEY, DEFAULT_METADATA_PUBLISH_DELAY), TimeUnit.MILLISECONDS);
           }
   ```
   
   ```
       public void blockUntilUpdated() {
           try {
               metadataSemaphore.tryAcquire(metadataPublishDelayTime, TimeUnit.MILLISECONDS);
               metadataSemaphore.drainPermits();
               updateLock.writeLock().lock();
           } catch (InterruptedException e) {
               if (!applicationModel.isDestroyed()) {
                   logger.warn("metadata refresh thread has been interrupted unexpectedly while waiting for update.", e);
               }
           }
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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