Skip to content
Browse files

Call ring_trans synchronously, not in a spawn

Calling `add_supported_to_ring` is not threadsafe.
If a process retrieves the member_meta and then
it's concurrently updated by another process,
the original process' changed will be overwritten.

To exhibit the original bug, I added a
timer:sleep(crypto:rand_uniform(1, 1000))
line inside the spawned fun that calls
riak_core_ring_manager:ring_trans(F, ok)
  • Loading branch information...
1 parent fc8a51f commit 094954d6ded786b917a2d6dfe7f8097ba7d42975 @reiddraper reiddraper committed Sep 21, 2012
Showing with 1 addition and 3 deletions.
  1. +1 −3 src/riak_core_capability.erl
4 src/riak_core_capability.erl
@@ -377,9 +377,7 @@ publish_supported(State) ->
- spawn(fun() ->
- riak_core_ring_manager:ring_trans(F, ok)
- end),
+ riak_core_ring_manager:ring_trans(F, ok),
%% Add a node's capabilities to the provided ring

0 comments on commit 094954d

Please sign in to comment.
Something went wrong with that request. Please try again.