Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [3.3.4] Handling of PartitionChangeEvent in DefaultTbApiUsageStateService is synchronous. #6056

Closed
ashvayka opened this issue Feb 8, 2022 · 1 comment
Assignees
Labels
Milestone

Comments

@ashvayka
Copy link
Member

ashvayka commented Feb 8, 2022

Describe the bug
Based on the issue topic, the synchronous call of initStatesFromDataBase() causes a slow start on the demo.thingsboard.io cause we have ~100K tenants there.

Stacktrace:

tb-core1_1 | at org.thingsboard.server.dao.sql.tenant.JpaTenantDao.findTenantsByRegion(JpaTenantDao.java:63)
tb-core1_1 | at org.thingsboard.server.dao.sql.tenant.JpaTenantDao$$FastClassBySpringCGLIB$$bb4581c1.invoke()
tb-core1_1 | at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
tb-core1_1 | at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
tb-core1_1 | at org.thingsboard.server.dao.sql.tenant.JpaTenantDao$$EnhancerBySpringCGLIB$$217df218.findTenantsByRegion()
tb-core1_1 | at org.thingsboard.server.dao.tenant.TenantServiceImpl.findTenants(TenantServiceImpl.java:171)
tb-core1_1 | at org.thingsboard.server.service.apiusage.DefaultTbApiUsageStateService$$Lambda$1721/0x000000084103a040.fetch(Unknown Source)
tb-core1_1 | at org.thingsboard.server.common.data.page.PageDataIterable.fetchPageData(PageDataIterable.java:29)
tb-core1_1 | at org.thingsboard.server.common.data.page.BasePageDataIterable.fetch(BasePageDataIterable.java:65)
tb-core1_1 | at org.thingsboard.server.common.data.page.BasePageDataIterable.hasNext(BasePageDataIterable.java:50)
tb-core1_1 | at org.thingsboard.server.service.apiusage.DefaultTbApiUsageStateService.initStatesFromDataBase(DefaultTbApiUsageStateService.java:494)
tb-core1_1 | at org.thingsboard.server.service.apiusage.DefaultTbApiUsageStateService.onTbApplicationEvent(DefaultTbApiUsageStateService.java:228)
tb-core1_1 | at org.thingsboard.server.service.apiusage.DefaultTbApiUsageStateService.onTbApplicationEvent(DefaultTbApiUsageStateService.java:88)
tb-core1_1 | at org.thingsboard.server.queue.discovery.TbApplicationEventListener.onApplicationEvent(TbApplicationEventListener.java:44)
tb-core1_1 | at org.thingsboard.server.queue.discovery.TbApplicationEventListener.onApplicationEvent(TbApplicationEventListener.java:25)
tb-core1_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
tb-core1_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
tb-core1_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
tb-core1_1 | at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
tb-core1_1 | at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
tb-core1_1 | at org.thingsboard.server.queue.discovery.HashPartitionService.lambda$recalculatePartitions$7(HashPartitionService.java:174)
tb-core1_1 | at org.thingsboard.server.queue.discovery.HashPartitionService$$Lambda$1717/0x000000084103b040.accept(Unknown Source)
tb-core1_1 | at java.util.concurrent.ConcurrentHashMap.forEach(java.base@11.0.12/ConcurrentHashMap.java:1603)
tb-core1_1 | at org.thingsboard.server.queue.discovery.HashPartitionService.recalculatePartitions(HashPartitionService.java:168)
tb-core1_1 | - locked <0x0000000083d4d568> (a org.thingsboard.server.queue.discovery.HashPartitionService)
tb-core1_1 | at org.thingsboard.server.queue.discovery.ZkDiscoveryService.recalculatePartitions(ZkDiscoveryService.java:301)
tb-core1_1 | - locked <0x00000000853888f0> (a org.thingsboard.server.queue.discovery.ZkDiscoveryService)
tb-core1_1 | at org.thingsboard.server.queue.discovery.ZkDiscoveryService.childEvent(ZkDiscoveryService.java:289)

@ashvayka
Copy link
Member Author

Fixed and merged to master: #6131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants