recursively mark puts during the critical section

This commit is contained in:
vyzo 2022-01-31 17:26:08 +02:00
parent 1abfc5b1cf
commit 2b14bda6b8
2 changed files with 18 additions and 8 deletions

View File

@ -370,10 +370,10 @@ func (s *SplitStore) Put(ctx context.Context, blk blocks.Block) error {
}
s.txnLk.RLock()
defer s.txnLk.RUnlock()
err := s.hot.Put(ctx, blk)
if err != nil {
s.txnLk.RUnlock()
return err
}
@ -381,8 +381,13 @@ func (s *SplitStore) Put(ctx context.Context, blk blocks.Block) error {
// critical section
if s.txnMarkSet != nil {
return s.txnMarkSet.Mark(blk.Cid())
go func() {
defer s.txnLk.RUnlock()
s.markLiveRefs([]cid.Cid{blk.Cid()})
}()
return nil
}
defer s.txnLk.RUnlock()
s.trackTxnRef(blk.Cid())
return nil
@ -420,10 +425,10 @@ func (s *SplitStore) PutMany(ctx context.Context, blks []blocks.Block) error {
}
s.txnLk.RLock()
defer s.txnLk.RUnlock()
err := s.hot.PutMany(ctx, blks)
if err != nil {
s.txnLk.RUnlock()
return err
}
@ -431,8 +436,13 @@ func (s *SplitStore) PutMany(ctx context.Context, blks []blocks.Block) error {
// critical section
if s.txnMarkSet != nil {
return s.txnMarkSet.MarkMany(batch)
go func() {
defer s.txnLk.RUnlock()
s.txnMarkSet.MarkMany(batch)
}()
return nil
}
defer s.txnLk.RUnlock()
s.trackTxnRefMany(batch)
return nil

View File

@ -160,7 +160,7 @@ func (s *SplitStore) protectTipSets(apply []*types.TipSet) {
if s.txnMarkSet != nil {
go func() {
defer s.txnLk.RUnlock()
s.markTipSetRefs(cids)
s.markLiveRefs(cids)
}()
return
}
@ -169,8 +169,8 @@ func (s *SplitStore) protectTipSets(apply []*types.TipSet) {
s.txnLk.RUnlock()
}
func (s *SplitStore) markTipSetRefs(cids []cid.Cid) {
log.Info("marking %d tipset refs", len(cids))
func (s *SplitStore) markLiveRefs(cids []cid.Cid) {
log.Info("marking %d live refs", len(cids))
startMark := time.Now()
workch := make(chan cid.Cid, len(cids))
@ -225,7 +225,7 @@ func (s *SplitStore) markTipSetRefs(cids []cid.Cid) {
log.Errorf("error marking tipset refs: %s", err)
}
log.Infow("marking tipset refs done", "took", time.Since(startMark), "marked", *count)
log.Infow("marking live refs done", "took", time.Since(startMark), "marked", *count)
}
// transactionally protect a view