add Sync to the tracking store

This commit is contained in:
vyzo 2021-02-27 18:16:09 +02:00
parent 364076c1ea
commit 783dcda19c
4 changed files with 16 additions and 0 deletions

View File

@ -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
}

View File

@ -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()
}

View File

@ -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()

View File

@ -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