From 7bc915c0d12117038aed4c932ebd29dba91b3ac9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 15 May 2020 14:35:29 -0700 Subject: [PATCH] Abort if the open fd limit cannot be increased (bp #10064) (#10074) automerge --- ledger/src/blockstore.rs | 10 +++++++--- ledger/src/blockstore_db.rs | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 6a839ba8ad16e8..b16fdda78f9456 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -178,7 +178,7 @@ impl Blockstore { fs::create_dir_all(&ledger_path)?; let blockstore_path = ledger_path.join(BLOCKSTORE_DIRECTORY); - adjust_ulimit_nofile(); + adjust_ulimit_nofile()?; // Open the database let mut measure = Measure::start("open"); @@ -2809,10 +2809,12 @@ pub fn make_chaining_slot_entries( } #[cfg(not(unix))] -fn adjust_ulimit_nofile() {} +fn adjust_ulimit_nofile() -> Result<()> { + Ok(()) +} #[cfg(unix)] -fn adjust_ulimit_nofile() { +fn adjust_ulimit_nofile() -> Result<()> { // Rocks DB likes to have many open files. The default open file descriptor limit is // usually not enough let desired_nofile = 65000; @@ -2840,11 +2842,13 @@ fn adjust_ulimit_nofile() { if cfg!(target_os = "macos") { error!("On mac OS you may need to run |sudo launchctl limit maxfiles 65536 200000| first"); } + return Err(BlockstoreError::UnableToSetOpenFileDescriptorLimit); } nofile = get_nofile(); } info!("Maximum open file descriptors: {}", nofile.rlim_cur); + Ok(()) } #[cfg(test)] diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs index ae94c722f302b2..dbbf5e1a78f16d 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -55,6 +55,7 @@ pub enum BlockstoreError { Serialize(#[from] Box), FsExtraError(#[from] fs_extra::error::Error), SlotCleanedUp, + UnableToSetOpenFileDescriptorLimit, } pub type Result = std::result::Result;