You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ta...@apache.org on 2022/07/29 02:22:29 UTC

[flink-docker] branch dev-1.15 updated: [FLINK-28057] Fix LD_PRELOAD on ARM images

This is an automated email from the ASF dual-hosted git repository.

tangyun pushed a commit to branch dev-1.15
in repository https://gitbox.apache.org/repos/asf/flink-docker.git


The following commit(s) were added to refs/heads/dev-1.15 by this push:
     new ff2d078  [FLINK-28057] Fix LD_PRELOAD on ARM images
ff2d078 is described below

commit ff2d07865f2f0d4a0adfda3525a42a5d758c64bb
Author: Nicolas Ferrario <nf...@mediamath.com>
AuthorDate: Thu Jul 28 21:42:37 2022 +0200

    [FLINK-28057] Fix LD_PRELOAD on ARM images
---
 docker-entrypoint.sh             | 15 ++++++++++++++-
 testing/bin/docker-entrypoint.sh | 12 ++++++++++--
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 84fca0c..8b0350e 100755
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -91,7 +91,20 @@ prepare_configuration() {
 
 maybe_enable_jemalloc() {
     if [ "${DISABLE_JEMALLOC:-false}" == "false" ]; then
-        export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libjemalloc.so
+        JEMALLOC_PATH="/usr/lib/$(uname -m)-linux-gnu/libjemalloc.so"
+        JEMALLOC_FALLBACK="/usr/lib/x86_64-linux-gnu/libjemalloc.so"
+        if [ -f "$JEMALLOC_PATH" ]; then
+            export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_PATH
+        elif [ -f "$JEMALLOC_FALLBACK" ]; then
+            export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_FALLBACK
+        else
+            if [ "$JEMALLOC_PATH" = "$JEMALLOC_FALLBACK" ]; then
+                MSG_PATH=$JEMALLOC_PATH
+            else
+                MSG_PATH="$JEMALLOC_PATH and $JEMALLOC_FALLBACK"
+            fi
+            echo "WARNING: attempted to load jemalloc from $MSG_PATH but the library couldn't be found. glibc will be used instead."
+        fi
     fi
 }
 
diff --git a/testing/bin/docker-entrypoint.sh b/testing/bin/docker-entrypoint.sh
index 5df2015..4c90753 100755
--- a/testing/bin/docker-entrypoint.sh
+++ b/testing/bin/docker-entrypoint.sh
@@ -27,11 +27,19 @@ originalLdPreloadSetting=$3
 jemallocDisabled=$4
 
 if [ "$jemallocDisabled" == "true" ] && ! [ "$originalLdPreloadSetting" == "$LD_PRELOAD" ]; then
-    echo "jemalloc was not disabled; expected LD_PRELOAD to be '$originalLdPreloadSetting' but was '$LD_PRELOAD'"
+    echo "jemalloc was disabled; expected LD_PRELOAD to be '$originalLdPreloadSetting' but was '$LD_PRELOAD'"
     exit 1
 fi
 
+# We expect jemalloc to be available in any of these paths
+JEMALLOC_PATH="/usr/lib/$(uname -m)-linux-gnu/libjemalloc.so"
+JEMALLOC_FALLBACK="/usr/lib/x86_64-linux-gnu/libjemalloc.so"
+
 if [ "$jemallocDisabled" == "false" ] && [ "$originalLdPreloadSetting" == "$LD_PRELOAD" ]; then
-    echo "jemalloc was disabled; expected LD_PRELOAD to be different than '$originalLdPreloadSetting'."
+    if [ ! -f "$JEMALLOC_PATH" ] && [ ! -f "$JEMALLOC_FALLBACK" ]; then
+      echo "jemalloc was enabled but it was not found in the system. LD_PRELOAD is unchanged and glibc will be used instead."
+      exit 0
+    fi
+    echo "jemalloc was enabled; expected LD_PRELOAD to be different than '$originalLdPreloadSetting'."
     exit 1
 fi