From 33b33660431532129509f327be3a65367abd40f2 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 21 Jul 2019 13:49:59 -0700 Subject: [PATCH] volume: avoid compacting wait group --- weed/storage/volume.go | 1 - weed/storage/volume_read_write.go | 6 +----- weed/storage/volume_vacuum.go | 2 -- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/weed/storage/volume.go b/weed/storage/volume.go index a1d9d7e8d..a567b2e14 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -22,7 +22,6 @@ type Volume struct { Collection string dataFile *os.File nm NeedleMapper - compactingWg sync.WaitGroup needleMapKind NeedleMapType readOnly bool diff --git a/weed/storage/volume_read_write.go b/weed/storage/volume_read_write.go index d080e5dba..2f2eb81dc 100644 --- a/weed/storage/volume_read_write.go +++ b/weed/storage/volume_read_write.go @@ -136,11 +136,7 @@ func (v *Volume) deleteNeedle(n *needle.Needle) (uint32, error) { func (v *Volume) readNeedle(n *needle.Needle) (int, error) { nv, ok := v.nm.Get(n.Id) if !ok || nv.Offset.IsZero() { - v.compactingWg.Wait() - nv, ok = v.nm.Get(n.Id) - if !ok || nv.Offset.IsZero() { - return -1, ErrorNotFound - } + return -1, ErrorNotFound } if nv.Size == TombstoneFileSize { return -1, errors.New("already deleted") diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go index 3bb306649..89a0b1a14 100644 --- a/weed/storage/volume_vacuum.go +++ b/weed/storage/volume_vacuum.go @@ -46,8 +46,6 @@ func (v *Volume) CommitCompact() error { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() glog.V(3).Infof("Got volume %d committing lock...", v.Id) - v.compactingWg.Add(1) - defer v.compactingWg.Done() v.nm.Close() if err := v.dataFile.Close(); err != nil { glog.V(0).Infof("fail to close volume %d", v.Id)