-
Notifications
You must be signed in to change notification settings - Fork 546
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
Fix dual-read potential risk by using ThreadPool #945
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
brycezhongqing
force-pushed
the
zhonchen/threadPool
branch
from
November 10, 2023 01:01
a3041ec
to
677929c
Compare
PapaCharlie
reviewed
Nov 10, 2023
d2/src/main/java/com/linkedin/d2/xds/LoadBalanceTaskPool/NewLoadBalancerTaskthreadPool.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/xds/balancer/DualReadZkAndXdsLoadBalancerFactory.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/xds/LoadBalanceTaskPool/NewBalanceGetPropertiesTask.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/xds/LoadBalanceTaskPool/NewLoadBalancerTaskthreadPool.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/xds/balancer/DualReadZkAndXdsLoadBalancerFactory.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/xds/LoadBalanceTaskPool/NewLoadBalancerTaskthreadPool.java
Outdated
Show resolved
Hide resolved
whutwhu
reviewed
Nov 11, 2023
d2/src/main/java/com/linkedin/d2/xds/LoadBalanceTaskPool/NewLoadBalancerTaskthreadPool.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/xds/LoadBalanceTaskPool/NewLoadBalancerTaskthreadPool.java
Outdated
Show resolved
Hide resolved
brycezhongqing
force-pushed
the
zhonchen/threadPool
branch
2 times, most recently
from
November 11, 2023 21:01
b87968b
to
648e7ff
Compare
PapaCharlie
requested changes
Nov 13, 2023
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
PapaCharlie
requested changes
Nov 13, 2023
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
brycezhongqing
force-pushed
the
zhonchen/threadPool
branch
from
November 13, 2023 19:52
19395a9
to
9868e63
Compare
PapaCharlie
requested changes
Nov 13, 2023
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
brycezhongqing
force-pushed
the
zhonchen/threadPool
branch
4 times, most recently
from
November 13, 2023 22:13
ed33fc7
to
db93223
Compare
brycezhongqing
force-pushed
the
zhonchen/threadPool
branch
from
November 13, 2023 22:26
db93223
to
7322bc5
Compare
bohhyang
requested changes
Nov 13, 2023
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
brycezhongqing
force-pushed
the
zhonchen/threadPool
branch
from
November 14, 2023 01:27
bba6909
to
1dd9d1b
Compare
bohhyang
approved these changes
Nov 14, 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.
LGTM. Please resolve the conflict with master (Paul's change is also bumping the minor version, so you'll need to bump to 29.48.0)
PapaCharlie
requested changes
Nov 14, 2023
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
PapaCharlie
approved these changes
Nov 21, 2023
d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadLoadBalancer.java
Outdated
Show resolved
Hide resolved
PapaCharlie
approved these changes
Nov 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
During the
dual_read
mode for service discovery, thenew loadBalance
may impact theold loadBalance
. As observed, whennew_Lb.getProperites
is executed, it can potentially blockoldLb.getClient
due to their synchronous progress. Ifnew_Lb.getProperities
times out, it leads to the blocking ofoldLb
, resulting in a timeout for the request. To address this, it is essential to incorporate a fallback mechanism.Solution:
ExecutorService like ThreadPoolExecutor
to decouple(async)new loadBalance
andold loadBalance
. For eachnew loadBalance getProperities task
we will request a thread to process.There are some keypoints :
[1] We need to create a
ExecutorService
[2] We need to write the
fallback
logic[3] We shouldn't create a large
task queue
and we need to discard the task which could not be processed in time.[4] We should add the relative metrics and log.
[5] We need promise the code change is backward compatible
[6] We need to provide the api to
custimize
theExecutorService
likeThreadPoolExecutor
Test
[✅]./gradlew build
[✅] test in toki(a test service)