From e8d3eda3bc783f52cd88d9b729f56222c6b29fad Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 15 May 2020 12:14:21 -0700 Subject: [PATCH 1/2] Abort if the open fd limit cannot be increased (#10064) automerge (cherry picked from commit 7080fb9b37dd5d7f4c248b20b2ab6692f6d956d9) # Conflicts: # ledger/src/blockstore_db.rs --- ledger/src/blockstore.rs | 10 +++++++--- ledger/src/blockstore_db.rs | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 52c13e203aaa0c..5cf48f184ca8f1 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -177,7 +177,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"); @@ -2780,10 +2780,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; @@ -2811,11 +2813,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..24ee652317de0f 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -55,6 +55,11 @@ pub enum BlockstoreError { Serialize(#[from] Box), FsExtraError(#[from] fs_extra::error::Error), SlotCleanedUp, +<<<<<<< HEAD +======= + UnpackError(#[from] UnpackError), + UnableToSetOpenFileDescriptorLimit, +>>>>>>> 7080fb9b3... Abort if the open fd limit cannot be increased (#10064) } pub type Result = std::result::Result; From a07ee5c7a4d1337d505ab4c49afc969f6885bb4f Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 15 May 2020 13:12:45 -0700 Subject: [PATCH 2/2] Update blockstore_db.rs --- ledger/src/blockstore_db.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs index 24ee652317de0f..dbbf5e1a78f16d 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -55,11 +55,7 @@ pub enum BlockstoreError { Serialize(#[from] Box), FsExtraError(#[from] fs_extra::error::Error), SlotCleanedUp, -<<<<<<< HEAD -======= - UnpackError(#[from] UnpackError), UnableToSetOpenFileDescriptorLimit, ->>>>>>> 7080fb9b3... Abort if the open fd limit cannot be increased (#10064) } pub type Result = std::result::Result;