This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 137
Fix unknown exception caused by thread safety issue #2033
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
315157973
requested review from
BewareMyPower and
Demogorgon314
as code owners
December 28, 2023 12:12
Could you sign the CLA? |
BewareMyPower
approved these changes
Dec 29, 2023
Demogorgon314
previously approved these changes
Dec 29, 2023
BewareMyPower
suggested changes
Dec 29, 2023
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.
The spotbugs check failed:
Medium: Inconsistent synchronization of io.streamnative.pulsar.handlers.kop.storage.ReplicaManager$PendingProduceCallback.responseMap; locked 60% of time [io.streamnative.pulsar.handlers.kop.storage.ReplicaManager$PendingProduceCallback, io.streamnative.pulsar.handlers.kop.storage.ReplicaManager$PendingProduceCallback, io.streamnative.pulsar.handlers.kop.storage.ReplicaManager$PendingProduceCallback, io.streamnative.pulsar.handlers.kop.storage.ReplicaManager$PendingProduceCallback, io.streamnative.pulsar.handlers.kop.storage.ReplicaManager$PendingProduceCallback] Unsynchronized access at ReplicaManager.java:[line 119]Unsynchronized access at ReplicaManager.java:[line 121]Synchronized access at ReplicaManager.java:[line 127]Synchronized access at ReplicaManager.java:[line 125]Synchronized access at ReplicaManager.java:[line 133] IS2_INCONSISTENT_SYNC
You need to check the synchronized code blocks again.
BTW, in our private fork, this pending produce is removed and the timeout
field is not processed.
BewareMyPower
approved these changes
Dec 31, 2023
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2033 +/- ##
============================================
- Coverage 16.98% 16.96% -0.03%
+ Complexity 730 728 -2
============================================
Files 191 191
Lines 14310 14310
Branches 1339 1339
============================================
- Hits 2430 2427 -3
- Misses 11704 11705 +1
- Partials 176 178 +2
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Both the response thread and timeout detection thread will access PendingProduceCallback
This problem will easily occur when the sending latency is close to the timeout threshold.
Step-1: response thread and timeout detection thread access 1 at the same time, none of them meet the conditions for return
Step-2: timeout detection thread execute to 2, and set responseMap = null
Setp-3: response thread execute to 3, cause NPE
Modifications
Add synchronized
Documentation
no-need-doc