cosmos-sdk: cosmos-sdk don't have to sync db for each block
Summary
Currently we always WriteSync in commit event of each block, but we don’t have to do that because tendermint will replay the blocks for us if we lost some data.
Problem Definition
We do unnecessary sync in db writing.
Proposal
Conservative option:
- use
Writeinstead ofWriteSyncin commit
Aggressive option:
disable the WAL?risk losing data when pruning blocks.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (8 by maintainers)
yeah, I was assuming they are same db, it’s more tricky if they are different DBs. if they are different DBs, I think we need to sync the write of each store.
there are some good description of the commit pipeline here, so the atomic unit in rocksdb could be a batch group, which could be larger than a single batch, but definitely won’t commit a batch partially. and here is the rocksdb code comments about the sync option.
WriteSyncwill call fdatasync on the WAL file after write, that’s my understanding, I can find out some references in the implementation later.