From 8ddbd30df9641324f34ff978d8dcbd798eeced7c Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:53:39 +0100 Subject: [PATCH] fix(cli): remove static file providers from cache on `reth db stats` (#10887) --- crates/cli/commands/src/db/stats.rs | 6 ++++++ .../storage/provider/src/providers/static_file/manager.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/crates/cli/commands/src/db/stats.rs b/crates/cli/commands/src/db/stats.rs index a98dc23e7..051b4469a 100644 --- a/crates/cli/commands/src/db/stats.rs +++ b/crates/cli/commands/src/db/stats.rs @@ -249,6 +249,12 @@ impl Command { total_index_size += index_size; total_offsets_size += offsets_size; total_config_size += config_size; + + // Manually drop provider, otherwise removal from cache will deadlock. + drop(jar_provider); + + // Removes from cache, since if we have many files, it may hit ulimit limits + static_file_provider.remove_cached_provider(segment, fixed_block_range.end()); } if !self.detailed_segments { diff --git a/crates/storage/provider/src/providers/static_file/manager.rs b/crates/storage/provider/src/providers/static_file/manager.rs index bca34e4d2..8ed33cf19 100644 --- a/crates/storage/provider/src/providers/static_file/manager.rs +++ b/crates/storage/provider/src/providers/static_file/manager.rs @@ -358,6 +358,8 @@ impl StaticFileProvider { } /// Given a segment and block range it removes the cached provider from the map. + /// + /// CAUTION: cached provider should be dropped before calling this or IT WILL deadlock. pub fn remove_cached_provider( &self, segment: StaticFileSegment,