Skip to content

Commit

Permalink
use random:uniform/0 instead of os:pid/0 when constructing node name …
Browse files Browse the repository at this point in the history
…in append_node_suffix

Borrowing from https://github.com/basho/node_package/blob/4.0/priv/base/nodetool#L195, this will help reduce the risk of hitting the atom table limit, as was reported by one of our customers who was calling riak-admin continuously and frequently enough to trigger the atom table overflow.
  • Loading branch information
hmmr authored May 11, 2021
1 parent 6e8b874 commit 6e4368a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions priv/templates/nodetool
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ nodename(Name) ->
end.

append_node_suffix(Name, Suffix) ->
random:seed(os:timestamp()),
case re:split(Name, "@", [{return, list}, unicode]) of
[Node, Host] ->
list_to_atom(lists:concat([Node, Suffix, os:getpid(), "@", Host]));
list_to_atom(lists:concat([Node, Suffix, random:uniform(1000), "@", Host]));
[Node] ->
list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
list_to_atom(lists:concat([Node, Suffix, random:uniform(1000)]))
end.

%% convert string to erlang term
Expand Down

0 comments on commit 6e4368a

Please sign in to comment.