From 66fed7b125586385527eba69e62416aa3dfcc9f3 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Fri, 18 Oct 2024 11:14:39 +0700 Subject: [PATCH] save --- .../freezeblocks/block_snapshots.go | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/turbo/snapshotsync/freezeblocks/block_snapshots.go b/turbo/snapshotsync/freezeblocks/block_snapshots.go index b97231d3427..70bfe3a1f0a 100644 --- a/turbo/snapshotsync/freezeblocks/block_snapshots.go +++ b/turbo/snapshotsync/freezeblocks/block_snapshots.go @@ -279,9 +279,7 @@ func (s *DirtySegment) reopenSeg(dir string) (err error) { if s.refcount.Load() > 0 { return } - if s.Decompressor != nil { - return - } + s.closeSeg() s.Decompressor, err = seg.NewDecompressor(filepath.Join(dir, s.FileName())) if err != nil { return fmt.Errorf("%w, fileName: %s", err, s.FileName()) @@ -355,25 +353,37 @@ func (s *DirtySegment) reopenIdx(dir string) (err error) { if s.refcount.Load() > 0 { return nil } + + s.closeIdx() if s.Decompressor == nil { return nil } - for len(s.indexes) <= len(s.Type().Indexes()) { - s.indexes = append(s.indexes, nil) - } - - for i, index := range s.Type().Indexes() { - if s.indexes[i] != nil { - continue - } - - fileName := s.Type().IdxFileName(s.version, s.from, s.to, index) + //for len(s.indexes) <= len(s.Type().Indexes()) { + // s.indexes = append(s.indexes, nil) + //} + // + //for i, index := range s.Type().Indexes() { + // if s.indexes[i] != nil { + // continue + // } + // + // fileName := s.Type().IdxFileName(s.version, s.from, s.to, index) + // index, err := recsplit.OpenIndex(filepath.Join(dir, fileName)) + // if err != nil { + // return fmt.Errorf("%w, fileName: %s", err, fileName) + // } + // + // s.indexes[i] = index + //} + + for _, fileName := range s.Type().IdxFileNames(s.version, s.from, s.to) { index, err := recsplit.OpenIndex(filepath.Join(dir, fileName)) + if err != nil { return fmt.Errorf("%w, fileName: %s", err, fileName) } - s.indexes[i] = index + s.indexes = append(s.indexes, index) } return nil