[ https://issues.apache.org/jira/browse/CASSANDRA-15767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17577391#comment-17577391 ]
Stefan Miklosovic edited comment on CASSANDRA-15767 at 8/9/22 12:35 PM: ------------------------------------------------------------------------ I was debugging this jemalloc loading little bit more and there is also an issue with directory parsing where to look for that library. I updated my branch to reflect that. Directories to load that library from is base on this (1). That seems to be wrong on the first sight as ldconfig is present in Ubuntu, for example as well. I do not think we should decide what operating system (or its fork) we are on based on whether there is ldconfig command present as it is (or it might be) basically everywhere. Hence, even I am on Ubuntu, because I have ldconfig present, it will act as if I am on "Centos" and it will not include some paths. For example, if it was detected correctly, it would add these paths to search in (this is from Ubuntu Jelly). {code:java} $ cat /etc/ld.so.conf /etc/ld.so.conf.d/*.conf | grep '^/' /usr/local/lib /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu <------ my libjemalloc is here {code} So, it will not add the directory my lib is in so it will not find it. I derived Debian-based distribution from the fact if there is / is not /etc/lsb-release file. Then there is a different problem with symlinks. Some distributions will create a symlink from libjemalloc.so to a library file, like, libjemalloc.so.1 (or .2). However, not all distributions have symlinks. For example Ubuntu Jelly has just a proper file (libjemalloc.so.2) however Mint distribution has a symlink to these files. For that reason I changed the regexp to {noformat} .*/libjemalloc\.so.* {noformat} which will take into account symlinks as well as all other files. Then I sort them in reverse order if there are two libs of different number but there is no symlink, I filter duplicates via uniq and I take the first entry via head. (1) [https://github.com/apache/cassandra/blob/trunk/bin/cassandra#L140-L147] EDIT: we should make distribution parsing more robust, it seems to me that /etc/lsb-release is not enough as it can be present on rpm-based distro too. https://stackoverflow.com/questions/47838800/etc-lsb-release-vs-etc-os-release was (Author: smiklosovic): I was debugging this jemalloc loading little bit more and there is also an issue with directory parsing where to look for that library. I updated my branch to reflect that. Directories to load that library from is base on this (1). That seems to be wrong on the first sight as ldconfig is present in Ubuntu, for example as well. I do not think we should decide what operating system (or its fork) we are on based on whether there is ldconfig command present as it is (or it might be) basically everywhere. Hence, even I am on Ubuntu, because I have ldconfig present, it will act as if I am on "Centos" and it will not include some paths. For example, if it was detected correctly, it would add these paths to search in (this is from Ubuntu Jelly). {code:java} $ cat /etc/ld.so.conf /etc/ld.so.conf.d/*.conf | grep '^/' /usr/local/lib /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu <------ my libjemalloc is here {code} So, it will not add the directory my lib is in so it will not find it. I derived Debian-based distribution from the fact if there is / is not /etc/lsb-release file. Then there is a different problem with symlinks. Some distributions will create a symlink from libjemalloc.so to a library file, like, libjemalloc.so.1 (or .2). However, not all distributions have symlinks. For example Ubuntu Jelly has just a proper file (libjemalloc.so.2) however Mint distribution has a symlink to these files. For that reason I changed the regexp to {noformat} .*/libjemalloc\.so.* {noformat} which will take into account symlinks as well as all other files. Then I sort them in reverse order if there are two libs of different number but there is no symlink, I filter duplicates via uniq and I take the first entry via head. (1) [https://github.com/apache/cassandra/blob/trunk/bin/cassandra#L140-L147] > /usr/bin/cassandra looking for wrong libjemalloc.so file > -------------------------------------------------------- > > Key: CASSANDRA-15767 > URL: https://issues.apache.org/jira/browse/CASSANDRA-15767 > Project: Cassandra > Issue Type: Bug > Components: Local/Scripts > Reporter: Brian Bellrose > Priority: Normal > Labels: centos8, debian, jemalloc > > In /usr/sbin/cassandra > Linux) > if [ -z $CASSANDRA_LIBJEMALLOC ] ; then > which ldconfig > /dev/null 2>&1 > if [ $? = 0 ] ; then > # e.g. for CentOS > dirs="/lib64 /lib /usr/lib64 /usr/lib `ldconfig -v 2>/dev/null | grep -v > '^\s' | sed 's/^\([^:]*\):.*$/\1/'`" > else > # e.g. for Debian, OpenSUSE > dirs="/lib64 /lib /usr/lib64 /usr/lib `cat /etc/ld.so.conf > /etc/ld.so.conf.d/*.conf | grep '^/'`" > fi > dirs=`echo $dirs | tr " " ":"` > CASSANDRA_LIBJEMALLOC=$(find_library '.*/libjemalloc\.so\(\.1\)*' $dirs) > > However... > # find /usr/lib64 -name "*jemalloc*" > /usr/lib64/libjemalloc.so.2 > > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org