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 bdff0121eb
commit 9e5b7aaaa9
4 changed files with 10 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) {

View File

@ -23,6 +23,7 @@ public:
virtual size_t totalDiskspaceUsed() const override;
virtual bool FSlow() const override { return true; }
virtual size_t filedsRequired() const override;
private:
void setVersion(rocksdb::ColumnFamilyHandle*);
@ -55,6 +56,7 @@ RocksDBStorageFactory::RocksDBStorageFactory(const char *dbfile, int dbnum, cons
options.max_background_compactions = 4;
options.max_background_flushes = 2;
options.max_open_files = filedsRequired();
options.bytes_per_sync = 1048576;
options.compaction_pri = rocksdb::kMinOverlappingRatio;
options.compression = rocksdb::kNoCompression;
@ -130,6 +132,10 @@ void RocksDBStorageFactory::setVersion(rocksdb::ColumnFamilyHandle *handle)
throw status.ToString();
}
size_t RocksDBStorageFactory::filedsRequired() const {
return 256;
}
IStorage *RocksDBStorageFactory::create(int db, key_load_iterator iter, void *privdata)
{
++db; // skip default col family