Skip to content

Fix: Correct synchronization lock and add volatile for tpsControlMana…#13882

Merged
KomachiSion merged 1 commit into
alibaba:developfrom
wanna280:fix-grpc-connection-concurrency
Oct 13, 2025
Merged

Fix: Correct synchronization lock and add volatile for tpsControlMana…#13882
KomachiSion merged 1 commit into
alibaba:developfrom
wanna280:fix-grpc-connection-concurrency

Conversation

@wanna280

Copy link
Copy Markdown
Contributor

Fix: Correct synchronization lock and add volatile for tpsControlManager

This PR addresses two thread-safety issues in the double-checked locking pattern for tpsControlManager initialization:

  1. Fixed incorrect synchronization lock object:
    Changed from GrpcConnection.class.getClass() to GrpcConnection.class to ensure proper lock scope is properly scoped to the current class, preventing unnecessary global lock contention with other classes using similar locking patterns.

  2. Added volatile modifier to tpsControlManager:
    Added the volatile keyword to the tpsControlManager variable to ensure proper visibility of the initialized instance across multiple threads, which is a critical part of the double-checked locking pattern to prevent race conditions in instance initialization.

These changes improve both the correctness and performance of the concurrent initialization logic.

@CLAassistant

CLAassistant commented Oct 11, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@wuyfee

wuyfee commented Oct 13, 2025

Copy link
Copy Markdown

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@KomachiSion KomachiSion added the kind/enhancement Category issues or prs related to enhancement. label Oct 13, 2025
@KomachiSion KomachiSion added this to the 3.1.1 milestone Oct 13, 2025
@KomachiSion
KomachiSion merged commit d964cd7 into alibaba:develop Oct 13, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement Category issues or prs related to enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants