Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(libmdbx): Some options can only be set after mdbx_env_open #11328

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

wtdcode
Copy link
Contributor

@wtdcode wtdcode commented Sep 30, 2024

I'm building some application solely relying on reth libmdbx bindings because it's more actively maintained.

When trying to setup MDBX_opt_sync_bytes and MDBX_opt_sync_period, this returns EPERM which is confusing. After digging into the code, the two options are guarded by:

  case MDBX_opt_sync_bytes:
    // ...
    if (unlikely(!(env->me_flags & MDBX_ENV_ACTIVE)))
      return MDBX_EPERM;

And the only place to set MDBX_ENV_ACTIVE is in mdbx_env_open:

    env->me_flags = (flags & ~MDBX_FATAL_ERROR) | MDBX_ENV_ACTIVE;

Therefore, the two options should be set after mdbx_env_open.

I have checked other options and these two seem the only special ones. I also added EPERM error type to libmdbx::Error.

…bx_env_open

Or else, this will return EPERM, which also added in this commit
@mattsse mattsse added the A-db Related to the database label Sep 30, 2024
@onbjerg onbjerg added this pull request to the merge queue Sep 30, 2024
Merged via the queue into paradigmxyz:main with commit 92aeff0 Sep 30, 2024
36 checks passed
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants