reth
reth copied to clipboard
fix: disable db shrinking
When configuring libdbmx on DatabaseEnv::open, the shrink_threshold field is set to None, which actually results in the default of −1 being passed through to the underlying implementation at https://github.com/paradigmxyz/reth/blob/main/crates/storage/libmdbx-rs/src/environment.rs#L643
According to the libmdbx API documentation shrink_threshold is:
The shrink threshold in bytes, must be greater than zero to allow the database to shrink and
greater than growth_step to avoid shrinking right after grow. Negative value means "keep current
or use default". Default is 2*growth_step.
So, with the current setting, the resulting value for shrink_threshold is actually 8 GiB (given 4GiB of growth_step).
The fix in this PR consists of setting shrink_threshold in DatabaseEnv::open to Some(0), so that the value passed is 0 and db shrinking is disabled.