From 84cac993769d149e69520de407046dc924d503c3 Mon Sep 17 00:00:00 2001 From: Andrei Zavada Date: Mon, 24 May 2021 17:05:14 +0300 Subject: [PATCH 1/6] optionally allow static node name suffixes Instances of nodetool generate random node name suffxes to facilitate running multiple simultaneous calls in parallel. However, each time nodetool connects to the target node, a new atom is created on the latter. If this happens frequently and/or long enough, it will eventually crash the node as it hits the atom table limit. As a workaround, if the caller can guarantee calls are serialized and isolated in time, defining an env variable $NODETOOL_NODE_PREFIX will create identical atoms for node name prefix, thus avoiding generation of new atoms. The proposed change is complimentary to https://github.com/erlware/relx/pull/868, aiming to address the issue, reported by one of our customers, in which a riak node hit the atom table limit (yes, all of 1M+ entries) and crashed. A postmortem showed the table filled with `maint1a2b3c4d-riak@127.0.0.1`, accumulated over a period of time resulting from calls to `riak admin status` every 5 min. Note that I did not attempt to do any changes that may need to be done, to the same effect, in extended_bin_windows, as it's not straightforward for me which they would be (my knowledge of scripting in Windows is some 30 year old). --- priv/templates/extended_bin | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 7c4acdcdb..fe9d4eb69 100644 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -365,7 +365,14 @@ erl_eval() { # Generate a random id relx_gen_id() { - dd count=1 bs=4 if=/dev/urandom 2> /dev/null | od -x | head -n1 | awk '{print $2$3}' + # To prevent exhastion of atoms on target node, optionally avoid + # generation of random node prefixes, if it is guaranteed calls + # are entirely sequential. + if [ x != x$NODETOOL_NODE_PREFIX ]; then + echo $NODETOOL_NODE_PREFIX + else + dd count=1 bs=4 if=/dev/urandom 2> /dev/null | od -x | head -n1 | awk '{print $2$3}' + fi } # Control a node with nodetool if erl_call isn't from OTP-23+ From 20991537d8122892dbd97c75fbcc615dd6659d96 Mon Sep 17 00:00:00 2001 From: Andrei Zavada Date: Fri, 4 Jun 2021 19:41:54 +0300 Subject: [PATCH 2/6] wrap NODETOOL_NODE_PREFIX in quotes --- priv/templates/extended_bin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index fe9d4eb69..1815eb733 100644 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -368,8 +368,8 @@ relx_gen_id() { # To prevent exhastion of atoms on target node, optionally avoid # generation of random node prefixes, if it is guaranteed calls # are entirely sequential. - if [ x != x$NODETOOL_NODE_PREFIX ]; then - echo $NODETOOL_NODE_PREFIX + if [ x != x"$NODETOOL_NODE_PREFIX" ]; then + echo "$NODETOOL_NODE_PREFIX" else dd count=1 bs=4 if=/dev/urandom 2> /dev/null | od -x | head -n1 | awk '{print $2$3}' fi From 1f91e1d837960f2035fe67d02f54e71eb168c825 Mon Sep 17 00:00:00 2001 From: Andrei Zavada Date: Fri, 4 Jun 2021 20:16:12 +0300 Subject: [PATCH 3/6] check if NODETOOL_NODE_PREFIX is empty --- priv/templates/extended_bin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 1815eb733..e9924cee3 100644 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -368,8 +368,8 @@ relx_gen_id() { # To prevent exhastion of atoms on target node, optionally avoid # generation of random node prefixes, if it is guaranteed calls # are entirely sequential. - if [ x != x"$NODETOOL_NODE_PREFIX" ]; then - echo "$NODETOOL_NODE_PREFIX" + if [ -n "${NODETOOL_NODE_PREFIX}" ]; then + echo "${NODETOOL_NODE_PREFIX}" else dd count=1 bs=4 if=/dev/urandom 2> /dev/null | od -x | head -n1 | awk '{print $2$3}' fi From 9b67f4288bcee9278878e9be14cbe71cefce4e5f Mon Sep 17 00:00:00 2001 From: Andrei Zavada Date: Fri, 4 Jun 2021 20:44:02 +0300 Subject: [PATCH 4/6] test strings with -z, for consistency --- priv/templates/extended_bin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index e9924cee3..c2bf1efe2 100644 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -365,13 +365,13 @@ erl_eval() { # Generate a random id relx_gen_id() { - # To prevent exhastion of atoms on target node, optionally avoid + # To prevent exhaustion of atoms on target node, optionally avoid # generation of random node prefixes, if it is guaranteed calls # are entirely sequential. - if [ -n "${NODETOOL_NODE_PREFIX}" ]; then - echo "${NODETOOL_NODE_PREFIX}" - else + if [ -z "${NODETOOL_NODE_PREFIX}" ]; then dd count=1 bs=4 if=/dev/urandom 2> /dev/null | od -x | head -n1 | awk '{print $2$3}' + else + echo "${NODETOOL_NODE_PREFIX}" fi } From c5d1d7597cccfb8638be751721793bd2d6a50804 Mon Sep 17 00:00:00 2001 From: Andrei Zavada Date: Fri, 25 Jun 2021 19:43:48 +0300 Subject: [PATCH 5/6] remove support for otp <22 for windows & add otp-24 --- .github/workflows/wintest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wintest.yml b/.github/workflows/wintest.yml index 300cab0e0..ae09a9b5f 100644 --- a/.github/workflows/wintest.yml +++ b/.github/workflows/wintest.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: # Cannot test OTP 21 due to https://bugs.erlang.org/browse/ERL-644 (see also https://github.com/elixir-lang/elixir/issues/7774) - otp_version: [19, 20, 22, 23] + otp_version: [22, 23, 24] os: [windows-latest] steps: From ab4b64d74b4475b67f3da2219156bc65963d390b Mon Sep 17 00:00:00 2001 From: Andrei Zavada Date: Fri, 25 Jun 2021 22:09:41 +0300 Subject: [PATCH 6/6] Update wintest.yml no otp-24 for windows yet --- .github/workflows/wintest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wintest.yml b/.github/workflows/wintest.yml index ae09a9b5f..de5f35015 100644 --- a/.github/workflows/wintest.yml +++ b/.github/workflows/wintest.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: # Cannot test OTP 21 due to https://bugs.erlang.org/browse/ERL-644 (see also https://github.com/elixir-lang/elixir/issues/7774) - otp_version: [22, 23, 24] + otp_version: [22, 23] os: [windows-latest] steps: