Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
4b2def36
Commit
4b2def36
authored
7 years ago
by
David Garcia Quintas
Browse files
Options
Downloads
Patches
Plain Diff
Fix RR concurrent updates
parent
af724acc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
+38
-16
38 additions, 16 deletions
...ilters/client_channel/lb_policy/round_robin/round_robin.c
test/cpp/end2end/client_lb_end2end_test.cc
+5
-0
5 additions, 0 deletions
test/cpp/end2end/client_lb_end2end_test.cc
with
43 additions
and
16 deletions
src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
+
38
−
16
View file @
4b2def36
...
...
@@ -195,11 +195,28 @@ static void rr_subchannel_list_unref(grpc_exec_ctx *exec_ctx,
static
void
rr_subchannel_list_shutdown
(
grpc_exec_ctx
*
exec_ctx
,
rr_subchannel_list
*
subchannel_list
,
const
char
*
reason
)
{
if
(
subchannel_list
->
shutting_down
)
{
if
(
GRPC_TRACER_ON
(
grpc_lb_round_robin_trace
))
{
gpr_log
(
GPR_DEBUG
,
"Subchannel list %p already shutting down"
,
(
void
*
)
subchannel_list
);
}
return
;
};
if
(
GRPC_TRACER_ON
(
grpc_lb_round_robin_trace
))
{
gpr_log
(
GPR_DEBUG
,
"Shutting down subchannel_list %p"
,
(
void
*
)
subchannel_list
);
}
GPR_ASSERT
(
!
subchannel_list
->
shutting_down
);
subchannel_list
->
shutting_down
=
true
;
for
(
size_t
i
=
0
;
i
<
subchannel_list
->
num_subchannels
;
i
++
)
{
subchannel_data
*
sd
=
&
subchannel_list
->
subchannels
[
i
];
if
(
sd
->
subchannel
!=
NULL
)
{
// if subchannel isn't shutdown, unsubscribe.
if
(
GRPC_TRACER_ON
(
grpc_lb_round_robin_trace
))
{
gpr_log
(
GPR_DEBUG
,
"Unsubscribing from subchannel %p as part of shutting down "
"subchannel_list %p"
,
(
void
*
)
sd
->
subchannel
,
(
void
*
)
subchannel_list
);
}
grpc_subchannel_notify_on_state_change
(
exec_ctx
,
sd
->
subchannel
,
NULL
,
NULL
,
&
sd
->
connectivity_changed_closure
);
...
...
@@ -228,13 +245,14 @@ static size_t get_next_ready_subchannel_index_locked(
const
size_t
index
=
(
i
+
p
->
last_ready_subchannel_index
+
1
)
%
p
->
subchannel_list
->
num_subchannels
;
if
(
GRPC_TRACER_ON
(
grpc_lb_round_robin_trace
))
{
gpr_log
(
GPR_DEBUG
,
"[RR %p] checking subchannel %p, subchannel_list %p, index %lu: "
"state=%d"
,
(
void
*
)
p
,
(
void
*
)
p
->
subchannel_list
->
subchannels
[
index
].
subchannel
,
(
void
*
)
p
->
subchannel_list
,
(
unsigned
long
)
index
,
p
->
subchannel_list
->
subchannels
[
index
].
curr_connectivity_state
);
gpr_log
(
GPR_DEBUG
,
"[RR %p] checking subchannel %p, subchannel_list %p, index %lu: "
"state=%s"
,
(
void
*
)
p
,
(
void
*
)
p
->
subchannel_list
->
subchannels
[
index
].
subchannel
,
(
void
*
)
p
->
subchannel_list
,
(
unsigned
long
)
index
,
grpc_connectivity_state_name
(
p
->
subchannel_list
->
subchannels
[
index
].
curr_connectivity_state
));
}
if
(
p
->
subchannel_list
->
subchannels
[
index
].
curr_connectivity_state
==
GRPC_CHANNEL_READY
)
{
...
...
@@ -511,16 +529,27 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error
*
error
)
{
subchannel_data
*
sd
=
arg
;
round_robin_lb_policy
*
p
=
sd
->
subchannel_list
->
policy
;
if
(
GRPC_TRACER_ON
(
grpc_lb_round_robin_trace
))
{
gpr_log
(
GPR_DEBUG
,
"[RR %p] connectivity changed for subchannel %p, subchannel_list %p: "
"prev_state=%s new_state=%s p->shutdown=%d "
"sd->subchannel_list->shutting_down=%d error=%s"
,
(
void
*
)
p
,
(
void
*
)
sd
->
subchannel
,
(
void
*
)
sd
->
subchannel_list
,
grpc_connectivity_state_name
(
sd
->
prev_connectivity_state
),
grpc_connectivity_state_name
(
sd
->
pending_connectivity_state_unsafe
),
p
->
shutdown
,
sd
->
subchannel_list
->
shutting_down
,
grpc_error_string
(
error
));
}
// If the policy is shutting down, unref and return.
if
(
p
->
shutdown
)
{
rr_subchannel_list_unref
(
exec_ctx
,
sd
->
subchannel_list
,
"pol_shutdown"
);
GRPC_LB_POLICY_WEAK_UNREF
(
exec_ctx
,
&
p
->
base
,
"pol_shutdown"
);
return
;
}
if
(
sd
->
subchannel_list
->
shutting_down
)
{
if
(
sd
->
subchannel_list
->
shutting_down
&&
error
==
GRPC_ERROR_CANCELLED
)
{
// the subchannel list associated with sd has been discarded. This callback
// corresponds to the unsubscription.
GPR_ASSERT
(
error
==
GRPC_ERROR_CANCELLED
);
rr_subchannel_list_unref
(
exec_ctx
,
sd
->
subchannel_list
,
"sl_shutdown"
);
GRPC_LB_POLICY_WEAK_UNREF
(
exec_ctx
,
&
p
->
base
,
"sl_shutdown"
);
return
;
...
...
@@ -536,13 +565,6 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
// state (which was set by the connectivity state watcher) to
// curr_connectivity_state, which is what we use inside of the combiner.
sd
->
curr_connectivity_state
=
sd
->
pending_connectivity_state_unsafe
;
if
(
GRPC_TRACER_ON
(
grpc_lb_round_robin_trace
))
{
gpr_log
(
GPR_DEBUG
,
"[RR %p] connectivity changed for subchannel %p: "
"prev_state=%d new_state=%d"
,
(
void
*
)
p
,
(
void
*
)
sd
->
subchannel
,
sd
->
prev_connectivity_state
,
sd
->
curr_connectivity_state
);
}
// Update state counters and determine new overall state.
update_state_counters_locked
(
sd
);
sd
->
prev_connectivity_state
=
sd
->
curr_connectivity_state
;
...
...
This diff is collapsed.
Click to expand it.
test/cpp/end2end/client_lb_end2end_test.cc
+
5
−
0
View file @
4b2def36
...
...
@@ -463,6 +463,11 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) {
EXPECT_EQ
(
"round_robin"
,
channel_
->
GetLoadBalancingPolicyName
());
}
TEST_F
(
ClientLbEnd2endTest
,
RoundRobinConcurrentUpdates
)
{
// TODO(dgq): replicate the way internal testing exercises the concurrent
// update provisions of RR.
}
TEST_F
(
ClientLbEnd2endTest
,
RoundRobinReconnect
)
{
// Start servers and send one RPC per server.
const
int
kNumServers
=
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment