8000 optimize: enhance close() logic of discovery module by YoWuwuuuw · Pull Request #7375 · apache/incubator-seata · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

optimize: enhance close() logic of discovery module #7375

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

Merged
merged 16 commits into from
Jun 12, 2025

Conversation

YoWuwuuuw
Copy link
Contributor
@YoWuwuuuw YoWuwuuuw commented May 28, 2025
  • I have registered the PR changes.

Ⅰ. Describe what this PR did

  1. Discovery module uses thread pool in many registration center modules. If the shutdown logic is not explicitly invoked, resource leakage may occur. So, shutdown the thread pool in close() method.
  2. Similarly, explicitly close the client in close() as best practice, If the client's lifecycle is controlled by the underlying layer, keep the original logic.
  3. RegistryHeartBeats.close() is only called in discovery-redis module, adding the logic to shutdown RegistryHeartBeats for discovery-consul module and discovery-etcd module(use RegistryHeartBeats in the same way).

Ⅱ. Does this pull request fix one issue?

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Copy link
codecov bot commented May 29, 2025

Codecov Report

Attention: Patch coverage is 63.63636% with 20 lines in your changes missing coverage. Please review.

Project coverage is 58.69%. Comparing base (bd717a6) to head (da32006).
Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...overy/registry/redis/RedisRegistryServiceImpl.java 61.11% 5 Missing and 2 partials ⚠️
...overy/registry/nacos/NacosRegistryServiceImpl.java 40.00% 4 Missing and 2 partials ⚠️
...covery/registry/etcd3/EtcdRegistryServiceImpl.java 71.42% 2 Missing and 2 partials ⚠️
...ery/registry/consul/ConsulRegistryServiceImpl.java 81.81% 0 Missing and 2 partials ⚠️
...e/seata/discovery/registry/RegistryHeartBeats.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7375      +/-   ##
============================================
+ Coverage     58.62%   58.69%   +0.07%     
- Complexity      571      575       +4     
============================================
  Files          1269     1269              
  Lines         45730    45774      +44     
  Branches       5548     5555       +7     
============================================
+ Hits          26807    26867      +60     
+ Misses        16344    16312      -32     
- Partials       2579     2595      +16     
Files with missing lines Coverage Δ
...scovery/registry/sofa/SofaRegistryServiceImpl.java 0.00% <ø> (ø)
...e/seata/discovery/registry/RegistryHeartBeats.java 70.00% <50.00%> (+4.48%) ⬆️
...ery/registry/consul/ConsulRegistryServiceImpl.java 63.07% <81.81%> (+2.74%) ⬆️
...covery/registry/etcd3/EtcdRegistryServiceImpl.java 77.01% <71.42%> (+5.49%) ⬆️
...overy/registry/nacos/NacosRegistryServiceImpl.java 27.97% <40.00%> (+12.78%) ⬆️
...overy/registry/redis/RedisRegistryServiceImpl.java 72.62% <61.11%> (+1.71%) ⬆️

... and 7 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I think tests should ideally not depend on execution order.
Would you mind sharing the reason why you chose to specify the order in this case? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RegistryService is a single instance mode. When testing the whole life cycle, it is generally required to follow the order of register-> lookup (subscribe) -> unregister-> close. Otherwise, if the test method is executed concurrently or the order is not fixed, the required resources will be destroyed.

Copy link
Contributor Author
8000

Choose a reason for hiding this comment

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

Or is there a better way to do it, and I do see lower efficiency in the test than in the normal test

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation!

Since it’s implemented as a singleton and shares internal static fields, it does make sense that tests could affect each other.

While it might be possible to make each test fully isolated, I agree that using @Order seems like a more practical solution in this case.

I don’t think any changes are needed in this case!

@YongGoose
Copy link
Member

I’ll take a look at the more urgent PRs first, and then come back to review this one!
Also time to start paying attention to the first coding phase of GSoC. 😅

Let’s keep it up and make GSoC a success together! 🙌

@YoWuwuuuw
Copy link
Contributor Author

我会先看看那些比较紧急的 PR,然后再回来审核这个! 现在也该开始关注 GSoC 的第一个编码阶段了。😅

让我们继续努力,共同推动 GSoC 取得成功!🙌

Ok.😄
In fact, I'm pushing GSoC every day!👍

@xingfudeshi xingfudeshi self-requested a review June 12, 2025 06:08
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 04447c7 into apache:2.x Jun 12, 2025
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0