diff --git a/erigon-lib/etl/dataprovider.go b/erigon-lib/etl/dataprovider.go index 1955cc83d5e..18c12f175e7 100644 --- a/erigon-lib/etl/dataprovider.go +++ b/erigon-lib/etl/dataprovider.go @@ -33,6 +33,7 @@ type dataProvider interface { Next(keyBuf, valBuf []byte) ([]byte, []byte, error) Dispose() // Safe for repeated call, doesn't return error - means defer-friendly Wait() error // join point for async providers + String() string } type fileDataProvider struct { @@ -126,9 +127,14 @@ func (p *fileDataProvider) Wait() error { return p.wg.Wait() } func (p *fileDataProvider) Dispose() { if p.file != nil { //invariant: safe to call multiple time p.Wait() - _ = p.file.Close() - go func(fPath string) { _ = os.Remove(fPath) }(p.file.Name()) + file := p.file p.file = nil + + go func() { + filePath := file.Name() + file.Close() + _ = os.Remove(filePath) + }() } }