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, ignore all relatived 
exceptions. 
   ```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);
           }
   ```
   
   ```java
       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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to