You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2016/12/10 00:35:48 UTC

[2/2] kudu git commit: KUDU-1798: [env] File manager broken on OS X 10.11

KUDU-1798: [env] File manager broken on OS X 10.11

Env::IncreaseOpenFileLimit() relies upon few system calls which behave
differently on OS X 10.11 than on Linux or other versions of macOS. See
the new comment in env_posix.cc for details.

Change-Id: Idb18b4e52ad80f89f61a92898c50c479643c12ec
Reviewed-on: http://gerrit.cloudera.org:8080/5438
Reviewed-by: Alexey Serbin <as...@cloudera.com>
Tested-by: Kudu Jenkins
(cherry picked from commit 8e1a8c550408bbd9c580d2dfe6fb22ce8e8c958c)
Reviewed-on: http://gerrit.cloudera.org:8080/5452
Reviewed-by: Jean-Daniel Cryans <jd...@apache.org>


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

Branch: refs/heads/branch-1.2.x
Commit: eaed73bde9eed2170df1447fbeb754b36eb0a996
Parents: 0f2e07e
Author: Dinesh Bhat <di...@cloudera.com>
Authored: Fri Dec 9 14:05:25 2016 +0530
Committer: Dan Burkert <da...@apache.org>
Committed: Sat Dec 10 00:35:35 2016 +0000

----------------------------------------------------------------------
 src/kudu/util/env-test.cc  |  8 ++++++++
 src/kudu/util/env_posix.cc | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/eaed73bd/src/kudu/util/env-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/env-test.cc b/src/kudu/util/env-test.cc
index f3c41d3..a90f0e1 100644
--- a/src/kudu/util/env-test.cc
+++ b/src/kudu/util/env-test.cc
@@ -552,6 +552,14 @@ TEST_F(TestEnv, TestIsDirectory) {
   ASSERT_FALSE(is_dir);
 }
 
+// Regression test for KUDU-1776.
+TEST_F(TestEnv, TestIncreaseOpenFileLimit) {
+  int64_t limit_before = env_->GetOpenFileLimit();
+  env_->IncreaseOpenFileLimit();
+  int64_t limit_after = env_->GetOpenFileLimit();
+  ASSERT_GE(limit_after, limit_before) << "Failed to retain/increase open file limit";
+}
+
 static Status TestWalkCb(vector<string>* actual,
                          Env::FileType type,
                          const string& dirname, const string& basename) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/eaed73bd/src/kudu/util/env_posix.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/env_posix.cc b/src/kudu/util/env_posix.cc
index 3f0be74..984e032 100644
--- a/src/kudu/util/env_posix.cc
+++ b/src/kudu/util/env_posix.cc
@@ -1259,6 +1259,22 @@ class PosixEnv : public Env {
     // This change is logged because it is process-wide.
     struct rlimit l;
     PCHECK(getrlimit(RLIMIT_NOFILE, &l) == 0);
+#if defined(__APPLE__)
+    // OS X 10.11 can return RLIM_INFINITY from getrlimit, but allows rlim_cur and
+    // rlim_max to be raised only as high as the value of the maxfilesperproc
+    // kernel variable. Emperically, this value is 10240 across all tested macOS
+    // versions. Testing on OS X 10.10 and macOS 10.12 revealed that getrlimit
+    // returns the true limits (not RLIM_INFINITY), rlim_max can *not* be raised
+    // (when running as non-root), and rlim_cur can only be raised as high as
+    // rlim_max (this is consistent with Linux).
+    // TLDR; OS X 10.11 is wack.
+    if (l.rlim_max == RLIM_INFINITY) {
+      uint64_t limit;
+      size_t len = sizeof(limit);
+      PCHECK(sysctlbyname("kern.maxfilesperproc", &limit, &len, nullptr, 0) == 0);
+      l.rlim_max = limit;
+    }
+#endif
     if (l.rlim_cur < l.rlim_max) {
       LOG(INFO) << Substitute("Raising process file limit from $0 to $1",
                               l.rlim_cur, l.rlim_max);