Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit fe60f5b

Browse files
committed
Abort if the open fd limit cannot be increased
1 parent 58ef02f commit fe60f5b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ledger/src/blockstore.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl Blockstore {
180180
fs::create_dir_all(&ledger_path)?;
181181
let blockstore_path = ledger_path.join(BLOCKSTORE_DIRECTORY);
182182

183-
adjust_ulimit_nofile();
183+
adjust_ulimit_nofile()?;
184184

185185
// Open the database
186186
let mut measure = Measure::start("open");
@@ -2987,10 +2987,12 @@ pub fn make_chaining_slot_entries(
29872987
}
29882988

29892989
#[cfg(not(unix))]
2990-
fn adjust_ulimit_nofile() {}
2990+
fn adjust_ulimit_nofile() -> Result<()> {
2991+
Ok(())
2992+
}
29912993

29922994
#[cfg(unix)]
2993-
fn adjust_ulimit_nofile() {
2995+
fn adjust_ulimit_nofile() -> Result<()> {
29942996
// Rocks DB likes to have many open files. The default open file descriptor limit is
29952997
// usually not enough
29962998
let desired_nofile = 65000;
@@ -3018,11 +3020,13 @@ fn adjust_ulimit_nofile() {
30183020
if cfg!(target_os = "macos") {
30193021
error!("On mac OS you may need to run |sudo launchctl limit maxfiles 65536 200000| first");
30203022
}
3023+
return Err(BlockstoreError::UnableToSetOpenFileDescriptorLimit);
30213024
}
30223025

30233026
nofile = get_nofile();
30243027
}
30253028
info!("Maximum open file descriptors: {}", nofile.rlim_cur);
3029+
Ok(())
30263030
}
30273031

30283032
#[cfg(test)]

ledger/src/blockstore_db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub enum BlockstoreError {
5656
FsExtraError(#[from] fs_extra::error::Error),
5757
SlotCleanedUp,
5858
UnpackError(#[from] UnpackError),
59+
UnableToSetOpenFileDescriptorLimit,
5960
}
6061
pub type Result<T> = std::result::Result<T, BlockstoreError>;
6162

0 commit comments

Comments
 (0)