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
This commit is contained in:
John Sully 2021-11-02 19:31:53 +00:00
parent 73215b2eeb
commit 9bd7f63ab1
3 changed files with 4 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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) {