Fixes for bor snapshots (#8270)

This commit is contained in:
ledgerwatch 2023-09-22 11:08:22 +01:00 committed by GitHub
parent 92446bfa66
commit ef1729214d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -963,6 +963,9 @@ func (r *BlockReader) borBlockByEventHash(txnHash common.Hash, segments []*BorEv
if sn.IdxBorTxnHash == nil { if sn.IdxBorTxnHash == nil {
continue continue
} }
if sn.IdxBorTxnHash.KeyCount() == 0 {
continue
}
reader := recsplit.NewIndexReader(sn.IdxBorTxnHash) reader := recsplit.NewIndexReader(sn.IdxBorTxnHash)
blockEventId := reader.Lookup(txnHash[:]) blockEventId := reader.Lookup(txnHash[:])
offset := sn.IdxBorTxnHash.OrdinalLookup(blockEventId) offset := sn.IdxBorTxnHash.OrdinalLookup(blockEventId)
@ -1041,6 +1044,9 @@ func (r *BlockReader) EventsByBlock(ctx context.Context, tx kv.Tx, hash common.H
if sn.IdxBorTxnHash == nil { if sn.IdxBorTxnHash == nil {
continue continue
} }
if sn.IdxBorTxnHash.KeyCount() == 0 {
continue
}
reader := recsplit.NewIndexReader(sn.IdxBorTxnHash) reader := recsplit.NewIndexReader(sn.IdxBorTxnHash)
blockEventId := reader.Lookup(borTxHash[:]) blockEventId := reader.Lookup(borTxHash[:])
offset := sn.IdxBorTxnHash.OrdinalLookup(blockEventId) offset := sn.IdxBorTxnHash.OrdinalLookup(blockEventId)

View File

@ -789,8 +789,8 @@ func (s *BorRoSnapshots) Files() (list []string) {
func (s *BorRoSnapshots) ReopenList(fileNames []string, optimistic bool) error { func (s *BorRoSnapshots) ReopenList(fileNames []string, optimistic bool) error {
s.Events.lock.Lock() s.Events.lock.Lock()
defer s.Events.lock.Unlock() defer s.Events.lock.Unlock()
s.Spans.lock.RLock() s.Spans.lock.Lock()
defer s.Spans.lock.RUnlock() defer s.Spans.lock.Unlock()
s.closeWhatNotInList(fileNames) s.closeWhatNotInList(fileNames)
var segmentsMax uint64 var segmentsMax uint64
@ -948,6 +948,8 @@ func (s *BorRoSnapshots) ReopenWithDB(db kv.RoDB) error {
func (s *BorRoSnapshots) Close() { func (s *BorRoSnapshots) Close() {
s.Events.lock.Lock() s.Events.lock.Lock()
defer s.Events.lock.Unlock() defer s.Events.lock.Unlock()
s.Spans.lock.Lock()
defer s.Spans.lock.Unlock()
s.closeWhatNotInList(nil) s.closeWhatNotInList(nil)
} }