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

bugfix: fix some problems in the automatic data source proxy #3130

Merged

Conversation

wangliang181230
Copy link
Contributor

@wangliang181230 wangliang181230 commented Sep 18, 2020

Ⅰ. Describe what this PR did

bugfix: fixed some problems in the automatic data source proxy.
修复自动数据源代理的一些问题,用户使用体验会更好,与第三方组件的兼容性也会更好。

注:从此PR是从 #2879 中拆分出来的。

此PR调整的内容:

  1. AT/XA代理类构造函数中解除代理,避免用户手动创建代理导致双重代理所致的各种未知问题;(借用了大佬 @slievrly 的PR optimize: optimize datasource proxy #2921 的代码,主要我这边新增了一个接口SeataDataSourceProxy)
  2. 在不需要执行AT/XA代理时,不进入代理类的方法,而是直接执行原来的DataSource的功能,避免一些不可预测的问题,增强seata与其他第三方组件的兼容性。
  3. 将1.1.0版本中所使用的生命周期时创建数据源代理的Bean恢复过来,并进行了改造。原本代理类会直接代替原来的数据源而成为bean,这次仅创建和初始化数据源代理,数据源bean还是原生的,不会改变。这样就不会产生1.1.0时的兼容性问题,同时解决了AT/XA在项目启动时未注册资源的问题了。
  4. 修复了 非springboot用户 使用@EnableAutoDataSourceProxy启用XA模式时,RootContext.DEFAULT_BRANCH_TYPE的值却为AT的BUG。

Ⅱ. Does this pull request fix one issue?

fixes #2857
fixes #3060
解决了 issue #2857 里的其中一种死锁的情况。

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2020

Codecov Report

Merging #3130 into develop will decrease coverage by 0.09%.
The diff coverage is 22.07%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3130      +/-   ##
=============================================
- Coverage      50.46%   50.36%   -0.10%     
- Complexity      3111     3114       +3     
=============================================
  Files            593      594       +1     
  Lines          19571    19625      +54     
  Branches        2427     2438      +11     
=============================================
+ Hits            9876     9885       +9     
- Misses          8702     8744      +42     
- Partials         993      996       +3     
Impacted Files Coverage Δ Complexity Δ
...ing/boot/autoconfigure/SeataAutoConfiguration.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ation/datasource/AutoDataSourceProxyRegistrar.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...g/annotation/datasource/DataSourceProxyHolder.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ion/datasource/SeataAutoDataSourceProxyAdvice.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...on/datasource/SeataAutoDataSourceProxyCreator.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...n/datasource/SeataDataSourceBeanPostProcessor.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
.../src/main/java/io/seata/core/model/BranchType.java 78.57% <40.00%> (-21.43%) 6.00 <4.00> (+1.00) ⬇️
...c/main/java/io/seata/core/context/RootContext.java 56.86% <42.85%> (-2.72%) 18.00 <0.00> (ø)
.../main/java/io/seata/rm/BaseDataSourceResource.java 30.18% <100.00%> (+1.34%) 11.00 <2.00> (+1.00)
...o/seata/rm/datasource/AbstractDataSourceProxy.java 14.28% <100.00%> (-8.80%) 2.00 <1.00> (+1.00) ⬇️
... and 6 more

@wangliang181230
Copy link
Contributor Author

@slievrly 我借用了 #2921 的一些代码,如果觉得不合理。我可以把这部分代码从我的PR中移除掉。
主要是我加了SeataDataSourceProxy接口类。

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wangliang181230 wangliang181230 changed the title optimize: opt the logic of executing data source proxy bugfix: fixed some errors in the automatic data source proxy Sep 30, 2020
@wangliang181230 wangliang181230 changed the title bugfix: fixed some errors in the automatic data source proxy bugfix: fixed some problems in the automatic data source proxy Sep 30, 2020
@wangliang181230 wangliang181230 changed the title bugfix: fixed some problems in the automatic data source proxy bugfix: fix some problems in the automatic data source proxy Sep 30, 2020
@wangliang181230
Copy link
Contributor Author

@xingfudeshi 这个PR从解决死锁BUG的PR里拆分出来了。麻烦Review一下。

Copy link
Member

@xingfudeshi xingfudeshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@xingfudeshi xingfudeshi merged commit 3862276 into apache:develop Oct 1, 2020
@wangliang181230 wangliang181230 deleted the optimize-data-source-proxy branch October 1, 2020 13:51
@slievrly slievrly self-requested a review October 2, 2020 14:11
@slievrly slievrly added this to the 1.4.0 milestone Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mode: AT AT transaction mode mode: XA XA transaction mode module/rm-datasource rm-datasource module type: bug Category issues or prs related to bug.
Projects
None yet
5 participants