Skip to content

Commit

Permalink
warn if mlockall is not working once enabled in settings (instead of …
Browse files Browse the repository at this point in the history
…debug logging), closes #1194.
  • Loading branch information
kimchy committed Aug 2, 2011
1 parent 885c80f commit 9e621af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions config/elasticsearch.yml
Expand Up @@ -7,18 +7,16 @@
#path.work: /path/to/work
#path.logs: /path/to/logs

# Force all memory to be locked, forcing the JVM to never swap
#bootstrap.mlockall: true

# Gateway Settings
# Controls when to start the initial recovery process when starting a new cluster
# allowing for better reused of existing data during recovery.
#gateway.recover_after_nodes: 1
#gateway.recover_after_time: 5m
#gateway.expected_nodes: 2

# Force all memory to be locked, forcing JVM to never swap
# (make sure to set MIN and MAX mem to the same value)
# In order to see if this works or not, set the `common.jna` logging to DEBUG level.
# A solution to “Unknown mlockall error 0” can be to set ulimit -l unlimited.
#bootstrap.mlockall: true

# Controls the minimum number of master eligible nodes this node should "see"
# in order to operate within the cluster.
# Set this to a higher value (2-4) when running more than 2 nodes in the cluster
Expand Down
Expand Up @@ -40,9 +40,9 @@ public class CLibrary {
try {
Native.register("c");
} catch (NoClassDefFoundError e) {
logger.debug("JNA not found. Native methods will be disabled.");
logger.warn("jna not found. native methods (mlockall) will be disabled.");
} catch (UnsatisfiedLinkError e) {
logger.debug("Unable to link C library. Native methods will be disabled.");
logger.debug("unable to link C library. native methods (mlockall) will be disabled.");
}
}

Expand Down
Expand Up @@ -43,12 +43,12 @@ public static void tryMlockall() {

if (errno != Integer.MIN_VALUE) {
if (errno == CLibrary.ENOMEM && System.getProperty("os.name").toLowerCase().contains("linux")) {
logger.debug("Unable to lock JVM memory (ENOMEM)."
logger.warn("Unable to lock JVM memory (ENOMEM)."
+ " This can result in part of the JVM being swapped out."
+ " Increase RLIMIT_MEMLOCK or run elasticsearch as root.");
} else if (!System.getProperty("os.name").toLowerCase().contains("mac")) {
// OS X allows mlockall to be called, but always returns an error
logger.debug("Unknown mlockall error " + errno);
logger.warn("Unknown mlockall error " + errno);
}
}
}
Expand Down

0 comments on commit 9e621af

Please sign in to comment.