Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-17780

libjemalloc2 is not detected by cassandra script

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Duplicate
    • None
    • Local/Scripts
    • None
    • Code
    • Normal
    • Normal
    • Adhoc Test
    • All
    • None
    • Hide

      ci build, package installation on a distribution where libmalloc2 is present instead of libmalloc1. libmalloc1 distros should still work the same.

      Show
      ci build, package installation on a distribution where libmalloc2 is present instead of libmalloc1. libmalloc1 distros should still work the same.

    Description

      I noticed that there was this log message when I started a Cassandra node on a machine in AWS on Ubuntu Jelly (22.04).

      WARN  [main] 2022-07-27 11:04:16,731 StartupChecks.java:200 - jemalloc shared library could not be preloaded to speed up memory allocations
      

      Hence, I went ahead and I tried to install that package, on 22.04, 

      $ apt search libjemalloc
      Sorting... Done
      Full Text Search... Done
      libjemalloc-dev/jammy 5.2.1-4ubuntu1 amd64
          development files and documentation for jemalloc
      
      libjemalloc2/jammy,now 5.2.1-4ubuntu1 amd64
          general-purpose scalable concurrent malloc(3) implementation 

      So I did apt install libjemalloc2.

      But the problems didnt go away because cassandra script didnt recognised it. The value of JVM property the jemalloc startup check is reading from is an environment property called CASSANDRA_LIBJEMALLOC (1) which is set by us looking into various library paths, trying to find "libjemalloc.so.1"(2). But there is no "1" version of it. We have version "2".

      $ sudo dpkg -L libjemalloc2
      /.
      /usr
      /usr/lib
      /usr/lib/x86_64-linux-gnu
      /usr/lib/x86_64-linux-gnu/libjemalloc.so.2  <---- our tasty libjemalloc
      /usr/share
      /usr/share/doc
      /usr/share/doc/libjemalloc2
      /usr/share/doc/libjemalloc2/README
      /usr/share/doc/libjemalloc2/changelog.Debian.gz
      /usr/share/doc/libjemalloc2/copyright

      (1) https://github.com/apache/cassandra/blob/cassandra-4.0/bin/cassandra#L160
      (2) https://github.com/apache/cassandra/blob/cassandra-4.0/bin/cassandra#L157

      I checked what Debian is offering and Bullseye and Buster do not have libjemalloc1 anymore, they have version 2, 1 is gone. Strech and Jessie have version 1 and not 2 (obviously). Ubuntu Jelly has 2, I am not sure when they started to ship 2 instead of 1 but I assume that if a user runs Cassandra on "anything recent", this is broken, jemalloc is not used and I think that performance can suffer quite significantly.

      This logic is present from 3.0 onwards.

      The patch should fix this and it should take both versions into account. I will provide patch with my solution shortly.

      Attachments

        Issue Links

          Activity

            People

              smiklosovic Stefan Miklosovic
              smiklosovic Stefan Miklosovic
              Stefan Miklosovic
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m