Unable to link C library native methods mlockall will be disabled – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 6.8-8.9

Briefly, this error occurs when Elasticsearch is unable to access the mlockall function in the C library. This function prevents Elasticsearch’s memory from being swapped to disk, which can degrade performance. To resolve this issue, you can either run Elasticsearch as a root user, or grant the mlockall permission to the Elasticsearch user. Alternatively, you can disable memory swapping on the system level. However, these solutions may have security implications, so they should be implemented with caution.

This guide will help you check for common problems that cause the log ” unable to link C library. native methods (mlockall) will be disabled. ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: bootstrap.

Log Context

Log “unable to link C library. native methods (mlockall) will be disabled.” classname is JNACLibrary.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

    static {
        try {
            Native.register("c");
        } catch (UnsatisfiedLinkError e) {
            logger.warn("unable to link C library. native methods (mlockall) will be disabled."; e);
        }
    }

    static native int mlockall(int flags);

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?