You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "Chenjp (via GitHub)" <gi...@apache.org> on 2024/04/17 02:31:34 UTC

Re: [I] AbstractCacheManager destroy Framework's executorService when shutdown [dubbo]

Chenjp commented on issue #13615:
URL: https://github.com/apache/dubbo/issues/13615#issuecomment-2060227910

   > > > Let's add a reference counter to track how many ApplicationModels are using it. We'll increase the count when an ApplicationModel starts and decrease it when one is destroyed. Then, in the destroy method, we only shut down executorService if the counter is at zero, ensuring it stays active while still needed. @huangqy17 @AlbumenJ
   > > 
   > > 
   > > 这样不行,如果靠计数为0就shutdown,后面我又启了一个applicationModel,再次传入这个frameworkmodel的executorservice,发现是terminated,仍是执行不了刷新cache
   > 
   >     1. Use a flag to indicate whether the ExecutorService is created by AbstractCacheManager.
   > 
   > 
   >     * This approach is straightforward but not elegant.
   > 
   > 
   >     2. Inject applicationModel into AbstractCacheManager and compare the executorService reference during destruction.
   > 
   > 
   >     * It's uncertain whether AbstractCacheManager will require applicationModel  in the future.
   > 
   > 
   >     3. Use frameworkmodel::executorservice and add a reference counter; perhaps the ExecutorService created by AbstractCacheManager is unnecessary.
   > 
   > 
   > The above are my suggestions, but they may not be correct
   > ## Do other executors in FrameworkExecutorRepository encounter a similar question?
   > 
   >     1. 使用flag标记是否由AbstractCacheManager创建
   > 
   > 
   >     * 简单但是不优雅
   > 
   > 
   >     2. 把applicationModel注入进AbstractCacheManager,删除的时候比较引用
   > 
   > 
   >     * 不确定applicationModel未来版本是否能用到
   > 
   > 
   >     3. 统一使用frameworkmodel的线程池+上引用计数,保证frameworkmodel线程池创建在前,也许不会有空指针的问题
   > 
   > 
   > 以上是一点小建议,不一定正确
   > 
   > 其他FrameworkExecutorRepository中的线程池不知道是否也有这个问题 @huangqy17
   
   fix in PR #14091, introduce disposable-registration mechanism which is elegant:
   1. when initialize - wrap new created Cache, CacheStore as Disposable and  registerDisposable().
   2. when initialize - if parameter executorService is NULL, then construct a new ExecutorService instance and registerDisposable(); otherwise treat the new ScheduledFuture as disposable.
   3. destroy registered disposable resource in FILO order. 


-- 
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