From 783dcda19cba29c83bd5a575d8bf13ef4a03bffb Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 27 Feb 2021 18:16:09 +0200 Subject: [PATCH] add Sync to the tracking store --- chain/store/splitstore/snoop.go | 1 + chain/store/splitstore/snoop_bolt.go | 5 +++++ chain/store/splitstore/snoop_lmdb.go | 4 ++++ chain/store/splitstore/splitstore.go | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/chain/store/splitstore/snoop.go b/chain/store/splitstore/snoop.go index 3a2b5f43e..b312cae93 100644 --- a/chain/store/splitstore/snoop.go +++ b/chain/store/splitstore/snoop.go @@ -13,6 +13,7 @@ type TrackingStore interface { Get(cid.Cid) (abi.ChainEpoch, error) Delete(cid.Cid) error ForEach(func(cid.Cid, abi.ChainEpoch) error) error + Sync() error Close() error } diff --git a/chain/store/splitstore/snoop_bolt.go b/chain/store/splitstore/snoop_bolt.go index 015a11838..5c305e91e 100644 --- a/chain/store/splitstore/snoop_bolt.go +++ b/chain/store/splitstore/snoop_bolt.go @@ -22,6 +22,7 @@ func NewBoltTrackingStore(path string) (*BoltTrackingStore, error) { db, err := bolt.Open(path, 0644, &bolt.Options{ Timeout: 1 * time.Second, + NoSync: true, }) if err != nil { return nil, err @@ -97,6 +98,10 @@ func (s *BoltTrackingStore) ForEach(f func(cid.Cid, abi.ChainEpoch) error) error }) } +func (s *BoltTrackingStore) Sync() error { + return s.db.Sync() +} + func (s *BoltTrackingStore) Close() error { return s.db.Close() } diff --git a/chain/store/splitstore/snoop_lmdb.go b/chain/store/splitstore/snoop_lmdb.go index 1eca73feb..225f5f199 100644 --- a/chain/store/splitstore/snoop_lmdb.go +++ b/chain/store/splitstore/snoop_lmdb.go @@ -155,6 +155,10 @@ func (s *LMDBTrackingStore) ForEach(f func(cid.Cid, abi.ChainEpoch) error) error }) } +func (s *LMDBTrackingStore) Sync() error { + return nil +} + func (s *LMDBTrackingStore) Close() error { s.env.CloseDBI(s.db) return s.env.Close() diff --git a/chain/store/splitstore/splitstore.go b/chain/store/splitstore/splitstore.go index 47398860a..31a60b49e 100644 --- a/chain/store/splitstore/splitstore.go +++ b/chain/store/splitstore/splitstore.go @@ -633,6 +633,12 @@ func (s *SplitStore) compactFull() { log.Infow("sweeping done", "took", time.Since(startSweep)) log.Infow("compaction stats", "hot", stHot, "cold", stCold, "dead", stDead) + err = s.snoop.Sync() + if err != nil { + // TODO do something better here + panic(err) + } + err = s.setBaseEpoch(coldEpoch) if err != nil { // TODO do something better here