cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [1/6] cassandra git commit: Add vm.max_map_count StartupCheck
Date Mon, 13 Feb 2017 11:04:43 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 51e3660c7 -> 3a570d744
  refs/heads/cassandra-3.11 ed45d5eb7 -> 01b91cce2
  refs/heads/trunk 1eaef3f9e -> ffc82b1ee


Add vm.max_map_count StartupCheck

patch by Jay Zhuang; reviewed by Stefania Alborghetti for CASSANDRA-13008


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3a570d74
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3a570d74
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3a570d74

Branch: refs/heads/cassandra-3.0
Commit: 3a570d744e938077784d8a24b1334c7b567543ed
Parents: 51e3660
Author: Jay Zhuang <jay.zhuang@yahoo.com>
Authored: Thu Feb 9 17:20:19 2017 +0000
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Mon Feb 13 10:57:30 2017 +0000

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/service/StartupChecks.java | 50 ++++++++++++++++++++
 .../cassandra/service/StartupChecksTest.java    |  7 +++
 3 files changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a570d74/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b720a0e..ac3d1ed 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.11
+ * Add vm.max_map_count StartupCheck (CASSANDRA-13008)
  * Hint related logging should include the IP address of the destination in addition to 
    host ID (CASSANDRA-13205)
  * Reloading logback.xml does not work (CASSANDRA-13173)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a570d74/src/java/org/apache/cassandra/service/StartupChecks.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StartupChecks.java b/src/java/org/apache/cassandra/service/StartupChecks.java
index ad6a104..756799e 100644
--- a/src/java/org/apache/cassandra/service/StartupChecks.java
+++ b/src/java/org/apache/cassandra/service/StartupChecks.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.service;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.*;
@@ -30,6 +31,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.Config;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.*;
@@ -74,6 +76,7 @@ public class StartupChecks
                                                                       inspectJvmOptions,
                                                                       checkJnaInitialization,
                                                                       initSigarLibrary,
+                                                                      checkMaxMapCount,
                                                                       checkDataDirs,
                                                                       checkSSTablesFormat,
                                                                       checkSystemKeyspaceState,
@@ -199,6 +202,53 @@ public class StartupChecks
         }
     };
 
+    public static final StartupCheck checkMaxMapCount = new StartupCheck()
+    {
+        private final long EXPECTED_MAX_MAP_COUNT = 1048575;
+        private final String MAX_MAP_COUNT_PATH = "/proc/sys/vm/max_map_count";
+
+        private long getMaxMapCount()
+        {
+            final Path path = Paths.get(MAX_MAP_COUNT_PATH);
+            try (final BufferedReader bufferedReader = Files.newBufferedReader(path))
+            {
+                final String data = bufferedReader.readLine();
+                if (data != null)
+                {
+                    try
+                    {
+                        return Long.parseLong(data);
+                    }
+                    catch (final NumberFormatException e)
+                    {
+                        logger.warn("Unable to parse {}.", path, e);
+                    }
+                }
+            }
+            catch (final IOException e)
+            {
+                logger.warn("IO exception while reading file {}.", path, e);
+            }
+            return -1;
+        }
+
+        public void execute()
+        {
+            if (!FBUtilities.hasProcFS())
+                return;
+
+            if (DatabaseDescriptor.getDiskAccessMode() == Config.DiskAccessMode.standard
&&
+                DatabaseDescriptor.getIndexAccessMode() == Config.DiskAccessMode.standard)
+                return; // no need to check if disk access mode is only standard and not
mmap
+
+            long maxMapCount = getMaxMapCount();
+            if (maxMapCount < EXPECTED_MAX_MAP_COUNT)
+                logger.warn("Maximum number of memory map areas per process (vm.max_map_count)
{} " +
+                            "is too low, recommended value: {}, you can change it with sysctl.",
+                            maxMapCount, EXPECTED_MAX_MAP_COUNT);
+        }
+    };
+
     public static final StartupCheck checkDataDirs = () ->
     {
         // check all directories(data, commitlog, saved cache) for existence and permission

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a570d74/test/unit/org/apache/cassandra/service/StartupChecksTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/service/StartupChecksTest.java b/test/unit/org/apache/cassandra/service/StartupChecksTest.java
index d32b1b1..0f30d3c 100644
--- a/test/unit/org/apache/cassandra/service/StartupChecksTest.java
+++ b/test/unit/org/apache/cassandra/service/StartupChecksTest.java
@@ -102,6 +102,13 @@ public class StartupChecksTest
         startupChecks.verify();
     }
 
+    @Test
+    public void maxMapCountCheck() throws Exception
+    {
+        startupChecks = startupChecks.withTest(StartupChecks.checkMaxMapCount);
+        startupChecks.verify();
+    }
+
     private void copyLegacyNonSSTableFiles(Path targetDir) throws IOException
     {
 


Mime
View raw message