Skip to content

fix(rocksdb): set max_open_files to prevent fd exhaustion#22005

Merged
joshieDo merged 2 commits intomainfrom
alexey/fix-rocksdb-max-open-files
Feb 9, 2026
Merged

fix(rocksdb): set max_open_files to prevent fd exhaustion#22005
joshieDo merged 2 commits intomainfrom
alexey/fix-rocksdb-max-open-files

Conversation

@gakonst
Copy link
Member

@gakonst gakonst commented Feb 9, 2026

Summary

Sets max_open_files=512 on RocksDB to prevent Too many open files errors on systems with the default ulimit -n 1024.

Motivation

RocksDB defaults to max_open_files=-1 (unlimited SST file handles). On systems with the default ulimit of 1024, this causes:

IO error: While open a file for random read: .../rocksdb/001487.sst: Too many open files (-1)

This is reproducible with CLI commands like reth db hash-storage-changesets on a mature database with many SST files.

Changes

  • Added DEFAULT_MAX_OPEN_FILES = 512 constant
  • Applied it in RocksDBBuilder::default_options()
  • 512 leaves headroom for MDBX, static files, networking, and other I/O within the default 1024 fd limit
  • RocksDB's internal table cache re-opens files on demand, so this has negligible read performance impact

Testing

cargo check -p reth-provider — passes clean.

Thread: https://tempoxyz.slack.com/archives/C0A87C21805/p1770672581138199

RocksDB defaults to max_open_files=-1 (unlimited), which fails with
'Too many open files' on systems with the default ulimit of 1024.

Set max_open_files=512 to stay within the default OS limit while
leaving headroom for MDBX, static files, and other I/O. RocksDB's
internal table cache re-opens files on demand, so this has negligible
performance impact.

Amp-Thread-ID: https://ampcode.com/threads/T-019c444f-7a4e-7324-b241-23ebf512aa7a
Co-authored-by: Amp <amp@ampcode.com>
@gakonst gakonst added the A-db Related to the database label Feb 9, 2026
@gakonst gakonst added the A-db Related to the database label Feb 9, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

⚠️ Changelog not found.

A changelog entry is required before merging. We've generated a suggested changelog based on your changes:

Preview
---
reth-provider: patch
---

Fixed RocksDB file descriptor exhaustion by setting `max_open_files` to 512, preventing fd limit errors on systems with default ulimit of 1024.

Add changelog to commit this to your branch.

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Feb 9, 2026
@joshieDo joshieDo added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit 3668575 Feb 9, 2026
41 checks passed
@joshieDo joshieDo deleted the alexey/fix-rocksdb-max-open-files branch February 9, 2026 22:44
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Feb 9, 2026
CarlBeek added a commit to CarlBeek/reth that referenced this pull request Feb 10, 2026
* paradigmxyz/main: (144 commits)
  feat(engine): add getPayloadBodiesV2 endpoints for EIP-7928 BAL support (paradigmxyz#21774)
  ci: skip scheduled workflows on forks (paradigmxyz#22022)
  chore: rm random log file (paradigmxyz#22023)
  chore: remove base.reth.rs public endpoint references (paradigmxyz#22019)
  feat(rpc): add `subscribeFinalizedChainNotifications` endpoint (paradigmxyz#22011)
  feat(trie): remove `SerialSparseTrie` (paradigmxyz#21808)
  fix(rocksdb): set max_open_files to prevent fd exhaustion (paradigmxyz#22005)
  refactor(txpool): rename and document validation methods (paradigmxyz#22008)
  feat(engine): prefetch withdrawal addresses in pre-warming (paradigmxyz#21966)
  refactor(pool): add IntoIter: Send bounds to avoid unnecessary Vec collect (paradigmxyz#22001)
  fix(rpc): enforce blockHash constraint in append_matching_block_logs (paradigmxyz#22007)
  chore: move Kurtosis failures to the hive slack channel  (paradigmxyz#21983)
  feat(rpc): propagate TransactionOrigin through send_transaction and batcher (paradigmxyz#21969)
  feat(engine): reorg depth commitment metric (paradigmxyz#21992)
  feat(storage): add use_hashed_state storage setting (paradigmxyz#21997)
  perf: better scheduling for storage roots computation (paradigmxyz#21987)
  chore(deps): bump alloy 1.6.2 -> 1.6.3 (paradigmxyz#21986)
  fix(stages): skip sender unwind when fully pruned (paradigmxyz#21988)
  chore(net): remove OP stack bootnodes (paradigmxyz#21984)
  ci: use depot for hive and kurtosis image builds, run daily (paradigmxyz#21976)
  ...

# Conflicts:
#	.github/workflows/compact.yml
#	.github/workflows/dependencies.yml
#	.github/workflows/docker-tag-latest.yml
#	.github/workflows/docker.yml
#	.github/workflows/e2e.yml
#	.github/workflows/hive.yml
#	.github/workflows/integration.yml
#	.github/workflows/kurtosis.yml
#	.github/workflows/lint.yml
#	.github/workflows/release.yml
#	.github/workflows/reproducible-build.yml
#	.github/workflows/stale.yml
#	.github/workflows/sync-era.yml
#	.github/workflows/sync.yml
#	.github/workflows/unit.yml
#	bin/reth/Cargo.toml
#	crates/cli/commands/src/node.rs
#	crates/node/core/src/node_config.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-db Related to the database

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants