Skip to content

Commit

Permalink
Problem: versiondb lag behind when os reboot
Browse files Browse the repository at this point in the history
Closes: crypto-org-chain#1301

Solution:
- do fsync when writing versiondb
  • Loading branch information
yihuang committed Jan 26, 2024
1 parent 8fd18dc commit 8256c05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [#1292](https://github.com/crypto-org-chain/cronos/pull/1292) memiavl cancel background snapshot rewriting when graceful shutdown.
- [#1294](https://github.com/crypto-org-chain/cronos/pull/1294) Update ethermint to fix and improve of debug_traceCall and eth_feeHistory.
- [#1302](https://github.com/crypto-org-chain/cronos/pull/1302) Fix concurrent map access in rootmulti store.
- [#]() Write versiondb with fsync

*January 5, 2024*

Expand Down
11 changes: 8 additions & 3 deletions versiondb/tsrocksdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ var (

_ versiondb.VersionStore = Store{}

defaultWriteOpts = grocksdb.NewDefaultWriteOptions()
defaultReadOpts = grocksdb.NewDefaultReadOptions()
defaultWriteOpts = grocksdb.NewDefaultWriteOptions()
defaultSyncWriteOpts = grocksdb.NewDefaultWriteOptions()
defaultReadOpts = grocksdb.NewDefaultReadOptions()
)

func init() {
defaultSyncWriteOpts.SetSync(true)
}

type Store struct {
db *grocksdb.DB
cfHandle *grocksdb.ColumnFamilyHandle
Expand Down Expand Up @@ -77,7 +82,7 @@ func (s Store) PutAtVersion(version int64, changeSet []types.StoreKVPair) error
}
}

return s.db.Write(defaultWriteOpts, batch)
return s.db.Write(defaultSyncWriteOpts, batch)
}

func (s Store) GetAtVersionSlice(storeKey string, key []byte, version *int64) (*grocksdb.Slice, error) {
Expand Down

0 comments on commit 8256c05

Please sign in to comment.