-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
bugfix: fix deadlock during springboot project startup #2879
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2879 +/- ##
=============================================
- Coverage 50.46% 50.30% -0.16%
+ Complexity 3111 3107 -4
=============================================
Files 593 593
Lines 19571 19571
Branches 2427 2428 +1
=============================================
- Hits 9876 9845 -31
- Misses 8702 8731 +29
- Partials 993 995 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job.I left a comment.
...a-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
…eadlock # Conflicts: # spring/src/main/java/io/seata/spring/annotation/datasource/SeataAutoDataSourceProxyAdvice.java
…eadlock # Conflicts: # seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
…eadlock # Conflicts: # seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.java
Codecov Report
@@ Coverage Diff @@
## develop #2879 +/- ##
=============================================
- Coverage 51.02% 50.86% -0.16%
+ Complexity 3279 3278 -1
=============================================
Files 612 612
Lines 20114 20113 -1
Branches 2518 2519 +1
=============================================
- Hits 10263 10231 -32
- Misses 8822 8853 +31
Partials 1029 1029
|
…eadlock # Conflicts: # seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
…eadlock # Conflicts: # seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/StarterConstants.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
修复springboot项目启动过程中的死锁问题。
目前碰到的死锁都是由main和timeoutChecker两个线程互锁造成的。
死锁有两种情况:
情况一:(注:这种情况已在1.4.0解决掉了 PR #3130)
SpringBootConfigurationProvider
获取property bean
时spring的DefaultSingletonBeanRegistry.getSingleton()
方法seata
服务发现功能并调用了RegistryFactory.getInstance()
,RegistryFactory.getInstance()
导致两个线程互锁了。
情况二:
SpringBootConfigurationProvider
获取property bean
时spring的DefaultSingletonBeanRegistry.getSingleton()
方法NettyClientChannelManager.acquireChannel()
方法NettyClientChannelManager.acquireChannel()
导致两个线程互锁了。
为了避免以上两种死锁,以及其他未知的死锁情况,此PR改动了以下内容:
seata相关的配置bean的创建优先于其他所有seata的bean,并提前设置到
PROPERTY_BEAN_MAP
中,让其他线程在获取配置时,无需再调用DefaultSingletonBeanRegistry.getSingleton()
方法,直接从PROPERTY_BEAN_MAP
中获取,以此避免死锁。拆分此PR
#3130 bugfix: fix some problems in the automatic data source proxy.
Ⅱ. Does this pull request fix one issue?
fixes #2857
fixes #2960 顺便解决此issue
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews