From 61517f8280844c406ab37638eaae2435bb41d350 Mon Sep 17 00:00:00 2001 From: firest Date: Fri, 18 Nov 2022 14:23:49 +0800 Subject: [PATCH] chore: make remsh node name away from the atom table overflow --- bin/emqx | 2 +- bin/nodetool | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/emqx b/bin/emqx index cdbb7c9de..04e6b201a 100755 --- a/bin/emqx +++ b/bin/emqx @@ -319,7 +319,7 @@ relx_rem_sh() { # Generate a random id relx_gen_id() { - od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}' + od -t u -N 4 /dev/urandom | head -n1 | awk '{print $2 % 1000}' } # Control a node diff --git a/bin/nodetool b/bin/nodetool index c3bfe5b3c..234dabb97 100755 --- a/bin/nodetool +++ b/bin/nodetool @@ -202,7 +202,12 @@ nodename(Name) -> this_node_name(Name) -> [Node, Host] = re:split(Name, "@", [{return, list}, unicode]), - list_to_atom(lists:concat(["remsh_maint_", Node, os:getpid(), "@", Host])). + list_to_atom(lists:concat(["remsh_maint_", Node, node_name_suffix_id(), "@", Host])). + +%% use the reversed value that from pid mod 1000 as the node name suffix +node_name_suffix_id() -> + Pid = os:getpid(), + string:slice(string:reverse(Pid), 0, 3). %% For windows??? create_mnesia_dir(DataDir, NodeName) ->