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 Write instead of WriteSync in commit

Aggressive option:

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

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.

I would like to confirm prior to changing anything 😉

What is the semantic difference between Write and WriteSync then?

WriteSync will call fdatasync on the WAL file after write, that’s my understanding, I can find out some references in the implementation later.