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

Nodedb followup: SafeNoSync #13550

Closed
AskAlexSharov opened this issue Jan 24, 2025 · 1 comment
Closed

Nodedb followup: SafeNoSync #13550

AskAlexSharov opened this issue Jan 24, 2025 · 1 comment
Assignees
Milestone

Comments

@AskAlexSharov
Copy link
Collaborator

AskAlexSharov commented Jan 24, 2025

Follow-up after: #13457 (comment)

Set mdbx_env_set_syncperiod and mdbx_env_set_syncbytes and call in goroutine mdbx_env_sync_ex.

mdbx doesn't have own thread: at all.
In SafeNoSync - it can call fsync in 2 cases:

  • or inside Commit (if some of limits reached in this rwtx)
  • or inside mdbx_env_sync_ex

So, SafeNoSync - increase latency of "unlucky" rwtx which reached limits. But we can reduce this probability by manually creating goroutine with periodical call of mdbx_env_sync_ex (then this goroutine will be blocked instead of "unlucky Commit")

I prefer SafeNoSync over .Batch because:

it allow reduce latency for most of writers. it doesn't hold writers until fsync. (maybe 1 writer holded - to perform fsync by this thread. i'm not 100% sure - maybe mdbx has background thread for fsync).
so with .Batch if set DefaultMaxBatchDelay to 2sec it will add latency of 2sec to all writers. but in SafeNoSync if set mdbx_env_set_syncperiod to 2sec it will not add any latency to writers.

with SafeNoSync - if kill -9 came in wrong time - it may leave DB in "bad" state:

  • if then open DB in rw mode: then mdbx can self-recover from "bad" state.
  • but if open DB in ro mode: then mdbx can't recover and exit with error (can't open db).

Let's remove ReadOnly mode of DB. RPCDaemon and integration tools - nothing will change if open in RW mode.

@AskAlexSharov AskAlexSharov added this to the 3.0.0-beta3 milestone Jan 24, 2025
@AskAlexSharov AskAlexSharov modified the milestones: 3.0.0, 3.1.0 Feb 12, 2025
AskAlexSharov pushed a commit that referenced this issue Feb 19, 2025
Currently the MDBX metrics recorded by `CollectMetrics()` are hardcoded
, and work only for the main `chaindata` MDBX instance.

In this PR I add a label to the MDBX metrics to denote the DB instance
for which the metrics are collected.

This will enable me to tune the performance of node DB :
#13550

---------

Co-authored-by: antonis19 <[email protected]>
@AskAlexSharov AskAlexSharov changed the title Nodedb followup: SaveNoSyn set 2 limits. Nodedb followup: SaveNoSyn Feb 22, 2025
@AskAlexSharov AskAlexSharov changed the title Nodedb followup: SaveNoSyn Nodedb followup: SafeNoSync Feb 23, 2025
AskAlexSharov pushed a commit that referenced this issue Feb 26, 2025
Release v0.38.6 of mdbx-go :
https://github.com/erigontech/mdbx-go/releases/tag/v0.38.6 includes
bindings for `mdbx_env_set_syncbytes` and `mdbx_env_get_syncbytes` ,
which will allow a more comprehensive assessment of MDBX using
`SafeNoSync` .

Related task: #13550

---------

Co-authored-by: antonis19 <[email protected]>
@antonis19
Copy link
Member

Closing with: #13980

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants