From 9bd7f63ab135563fea6f377deafe9f0d1d5b1060 Mon Sep 17 00:00:00 2001 From: John Sully Date: Tue, 2 Nov 2021 19:31:53 +0000 Subject: [PATCH] This change fixes out of file descriptor issues with FLASH. The change does 3 things: 1. It limits RocksDB to 256 file descriptors instead of unlimited 2. It includes the fd limit in its estimation for total file descriptors needed 3. It raises the system fd limit if possible before we open rocksdb but accounting for the 256 limit we added Former-commit-id: 1447288209c5e7daf8a1203511fc262500ebe5e1 --- src/IStorage.h | 1 + src/config.cpp | 1 + src/server.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/IStorage.h b/src/IStorage.h index d5808c4c1..d1f316022 100644 --- a/src/IStorage.h +++ b/src/IStorage.h @@ -12,6 +12,7 @@ public: virtual const char *name() const = 0; virtual size_t totalDiskspaceUsed() const = 0; virtual bool FSlow() const = 0; + virtual size_t filedsRequired() const { return 0; } }; class IStorage diff --git a/src/config.cpp b/src/config.cpp index e2028f4cc..7ef995bbd 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -357,6 +357,7 @@ bool initializeStorageProvider(const char **err) { // Create The Storage Factory (if necessary) serverLog(LL_NOTICE, "Initializing FLASH storage provider (this may take a long time)"); + adjustOpenFilesLimit(); g_pserver->m_pstorageFactory = CreateRocksDBStorageFactory(g_sdsArgs, cserver.dbnum, cserver.storage_conf, cserver.storage_conf ? strlen(cserver.storage_conf) : 0); } else if (!strcasecmp(g_sdsProvider, "test") && g_sdsArgs == nullptr) diff --git a/src/server.cpp b/src/server.cpp index 6540371d5..76a142efe 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3476,6 +3476,8 @@ int setOOMScoreAdj(int process_class) { * g_pserver->maxclients to the value that we can actually handle. */ void adjustOpenFilesLimit(void) { rlim_t maxfiles = g_pserver->maxclients+CONFIG_MIN_RESERVED_FDS; + if (g_pserver->m_pstorageFactory) + maxfiles += g_pserver->m_pstorageFactory->filedsRequired(); struct rlimit limit; if (getrlimit(RLIMIT_NOFILE,&limit) == -1) {