-
Notifications
You must be signed in to change notification settings - Fork 11.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
[ISSUE #4090]Fail faster to keep consistent state #4094
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4094 +/- ##
=============================================
+ Coverage 47.46% 47.94% +0.48%
- Complexity 4909 5008 +99
=============================================
Files 633 634 +1
Lines 42317 42537 +220
Branches 5544 5573 +29
=============================================
+ Hits 20086 20395 +309
+ Misses 19744 19639 -105
- Partials 2487 2503 +16
Continue to review full report at Codecov.
|
DefaultLitePullConsumer#start
导致的状态不一致问题】
DefaultLitePullConsumer#start
导致的状态不一致问题】public synchronized boolean isCreateJust() { | ||
return this.serviceState == ServiceState.CREATE_JUST; | ||
} | ||
|
||
public synchronized ServiceState getServiceState() { | ||
return this.serviceState; | ||
} | ||
|
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.
Is it necessary to add synchronized here?
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.
serviceState
is in a wrong/incompletable state before synchronized #start()
return, since the value of serviceState
is modified several times in synchronized #start()
. synchronized
in isCreateJust
and getServiceState
avoid read wrong/incompletable
value.
synchronized #start()
中对serviceState
进行了多次更新、并且方法返回之前的状态是 不正确/不完整 的,synchronized
是为了避免读取到这些 不正确/不完整 的状态。而且我注意到在该pr之前,serviceState
的修改和读取也都使用了synchronized
加锁、这已经可以保证serviceState
的可见性了,因此serviceState
上的volatile
修饰符似乎是多余的。
It's not a shared object. If there's a thread safety issue, it's probably not being used in the right way. |
@lwclover 非常感谢你的review. 首先 其次 综上,我认为 |
@RongtongJin @tianliuliu 请帮忙重新review,PR有两点更改:
|
Make sure set the target branch to
develop
What is the purpose of the change
#4090
Brief changelog
XX
Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR
.[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.