opengoofy / hippo4j

📌 异步线程池框架,支持线程池动态变更&监控&报警,无需修改代码轻松引入。Asynchronous thread pool framework, support Thread Pool Dynamic Change & monitoring & Alarm, no need to modify the code easily introduced.
https://hippo4j.cn
Apache License 2.0
5.59k stars 1.18k forks source link

[Bug] 相同租户、不同项目id、相同线程池id无法同时注册使用 #1525

Closed xx-ee closed 10 months ago

xx-ee commented 10 months ago

Search before asking

Environment

Windows

Hippo4j version

1.5.0

What happened

client端服务启动报错,提示“线程池配置已存在”

94bd73d724573ce808aab665add0515f

server端控制台大量报错

ccc9613e19460effe4856583f47046ff

How to reproduce

前提: 数据库config表:只存在1条记录:租户:hudong、项目id:hd-feed-ext-service-test、线程池id:feed-rednum-push-bath image

步骤:

  1. 启动第一个服务:租户:hudong、项目id:hd-feed-ext-service-test、线程池id:feed-rednum-push-bath,服务启动成功
  2. 启动第一个服务:租户:hudong、项目id:hd-feed-ext-service-dev、线程池id:feed-rednum-push-bath,服务启动失败,如图:
94bd73d724573ce808aab665add0515f

Debug logs

2023-12-19 15:37:00.699 [traceId:] [ ] [ ] |-INFO [main] cn.hippo4j.core.executor.DynamicThreadPoolExecutor [102] -| Initializing ExecutorService 'feed-rednum-push-bath' 2023-12-19 15:37:00.819 [traceId:] [ ] [ ] |-ERROR [main] cn.hippo4j.springboot.starter.support.DynamicThreadPoolConfigService [87] -| Dynamic thread pool registration execution error: feed-rednum-push-bath cn.hippo4j.common.web.exception.ServiceException: Dynamic thread pool registration returns error.线程池配置已存在 at cn.hippo4j.springboot.starter.support.DynamicThreadPoolConfigService.registerExecutor(DynamicThreadPoolConfigService.java:84) at cn.hippo4j.springboot.starter.support.DynamicThreadPoolConfigService.registerDynamicThreadPool(DynamicThreadPoolConfigService.java:69) at cn.hippo4j.core.executor.manage.GlobalThreadPoolManage.dynamicRegister(GlobalThreadPoolManage.java:117) at cn.hippo4j.springboot.starter.support.DynamicThreadPoolPostProcessor.fillPoolAndRegister(DynamicThreadPoolPostProcessor.java:164) at cn.hippo4j.springboot.starter.support.DynamicThreadPoolPostProcessor.postProcessAfterInitialization(DynamicThreadPoolPostProcessor.java:101) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:550) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:520) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:673) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:329) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:544) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:520) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:673) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:329) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) at com.sohu.tv.hd.feed.HudongFeedApplication.main(HudongFeedApplication.java:21) 2023-12-19 15:37:00.820 [traceId:] [ ] [ ] |-ERROR [main] cn.hippo4j.springboot.starter.support.DynamicThreadPoolPostProcessor [167] -| Failed to initialize thread pool configuration. error message: Dynamic thread pool registration returns error.线程池配置已存在 2023-12-19 15:37:00.832 [traceId:] [ ] [ ] |-ERROR [main] cn.hippo4j.springboot.starter.core.ClientWorker [220] -| Sub server namespace: hudong, itemId: hd-feed-ext-service-dev, threadPoolId: feed-rednum-push-bath, result code: 3 2023-12-19 15:37:00.832 [traceId:] [ ] [ ] |-ERROR [main] cn.hippo4j.springboot.starter.core.ClientWorker [276] -| Cache Data Error. Service Unavailable: null 2023-12-19 15:37:00.833 [traceId:] [ ] [ ] |-INFO [main] cn.hippo4j.springboot.starter.core.CacheData [68] -| Add listener status: ok, thread pool id: feed-rednum-push-bath, listeners count: 1

Are you willing to submit PR?

Code of Conduct

magestacks commented 10 months ago

From the initial design of the project metadata, the same thread pool ID is not allowed

There may be some reconstruction after version 2.0

xx-ee commented 10 months ago

不同项目之间的线程池id也不能相同吗,请问这种设计的初衷是?