Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix capability system race condition #216

Merged
merged 1 commit into from

2 participants

@jtuple

Prevent the node from crashing when the capability system attempts to
negotiate capabilities before the node has registered any capabilities.

@jtuple jtuple Fix capability system race condition
Prevent the node from crashing when the capability system attempts to
negotiate capabilities before the node has registered any capabilities.
8b6e04d
@Vagabond

Seems reasonable. +1 on visual review.

@jtuple jtuple merged commit abed2ad into 1.2
@seancribbs seancribbs deleted the jdb-capability-crash branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 22, 2012
  1. @jtuple

    Fix capability system race condition

    jtuple authored
    Prevent the node from crashing when the capability system attempts to
    negotiate capabilities before the node has registered any capabilities.
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 7 deletions.
  1. +11 −7 src/riak_core_capability.erl
View
18 src/riak_core_capability.erl
@@ -395,13 +395,17 @@ add_supported_to_ring(Node, Supported, Ring) ->
%% in the cluster.
negotiate_capabilities(Node, Override, State=#state{registered=Registered,
supported=Capabilities}) ->
- MyCaps = orddict:fetch(Node, Capabilities),
- N1 = reformat_capabilities(Registered, Capabilities),
- N2 = intersect_capabilities(N1),
- N3 = order_by_preference(MyCaps, N2),
- N4 = override_capabilities(N3, Override),
- N5 = [{Cap, hd(Common)} || {Cap, Common} <- N4],
- State#state{negotiated=N5}.
+ case orddict:find(Node, Capabilities) of
+ error ->
+ State;
+ {ok, MyCaps} ->
+ N1 = reformat_capabilities(Registered, Capabilities),
+ N2 = intersect_capabilities(N1),
+ N3 = order_by_preference(MyCaps, N2),
+ N4 = override_capabilities(N3, Override),
+ N5 = [{Cap, hd(Common)} || {Cap, Common} <- N4],
+ State#state{negotiated=N5}
+ end.
renegotiate_capabilities(State=#state{supported=[]}) ->
State;
Something went wrong with that request. Please try again.