apache / apache/incubator-seata

1.4.2 seata-springbootstarter 方式集成,读取配置超时

Open
#3,777 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
26k
Forks
8.8k
Avg merge
1d 8h
Merged PRs (30d)
4

Description

- [ ] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate.

### Ⅰ. Issue Description

SpringBootConfigurationProvider#get(dataId) 里面 获取 ConfigConsulProperties.class 这个bean 的时候卡住一段时间,大概有30秒,导致没有及时获取到consul连接配置,consul客户端没有及时完成初始化,这导致读取consul服务上配置数据超时失败
### Ⅱ. Describe what happened
```
ERROR 45365 --- [ main] io.seata.config.ConfigFuture : config operation timeout,cost:5000 ms,op:GET,dataId:transport.threadFactory.workerThreadPrefix
ERROR 45365 --- [ main] io.seata.config.ConfigFuture : config operation timeout,cost:5003 ms,op:GET,dataId:transport.threadFactory.shareBossWorker
ERROR 45365 --- [ main] io.seata.config.ConfigFuture : config operation timeout,cost:5000 ms,op:GET,dataId:transport.type
ERROR 45365 --- [ main] io.seata.config.ConfigFuture : config operation timeout,cost:5001 ms,op:GET,dataId:transport.threadFactory.workerThreadSize
```

### Ⅲ. Describe what you expected to happen

### Ⅳ. How to reproduce it (as minimally and precisely as possible)

分析如下:

1. ConfigurationFactory load registry配置文件的时候,在seata-springbootstarter环境下会被SpringBootConfigurationProvider 代理,所以ConfigurationFactory load 的registry 配置 是 yml 文件的 seata.regitry 配置内容;
2. ConfigurationFactory buildConfiguration 构造出来的配置类 也会被SpringBootConfigurationProvider代理,SpringBootConfigurationProvider 在读取 yml 中 seata.config.consul 这个配置内容时,是用 applicationContext.getBean(ConfigConsulProperties.class) 这个方式读取配置内容, 用这个方式这行getbean操作会卡住一段一时间,至少会卡住30秒以上,这样不能即使读取到consul的serveraddr配置内容,无法及时完成consulclient的初始化,也影响了 seatarm 初始化时获取配置;

3. 这个问题导致 项目启动时间过长;

### Ⅴ. Anything else we need to know?

### Ⅵ. Environment:

- JDK version : 1.8
- OS : centos 8
- Others:
seata: seata-spring-boot-starter 1.4.2
springboot: 2.3.10.RELEASE
配置中心: consul
注册中心: consul

Contributor guide

Open the contributing guide

Research direction

Start by tracing SpringBootConfigurationProvider#get(dataId) and how ConfigurationFactory loads and builds configuration in the Spring Boot starter. Inspect the ConfigConsulProperties lookup through applicationContext.getBean and the related initialization path. Done means startup no longer blocks for roughly 30 seconds and the Consul configuration is available before configuration reads time out.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.