mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume: avoid compacting wait group
This commit is contained in:
parent
4b15c8f0c4
commit
33b3366043
|
@ -22,7 +22,6 @@ type Volume struct {
|
||||||
Collection string
|
Collection string
|
||||||
dataFile *os.File
|
dataFile *os.File
|
||||||
nm NeedleMapper
|
nm NeedleMapper
|
||||||
compactingWg sync.WaitGroup
|
|
||||||
needleMapKind NeedleMapType
|
needleMapKind NeedleMapType
|
||||||
readOnly bool
|
readOnly bool
|
||||||
|
|
||||||
|
|
|
@ -135,13 +135,9 @@ func (v *Volume) deleteNeedle(n *needle.Needle) (uint32, error) {
|
||||||
// read fills in Needle content by looking up n.Id from NeedleMapper
|
// read fills in Needle content by looking up n.Id from NeedleMapper
|
||||||
func (v *Volume) readNeedle(n *needle.Needle) (int, error) {
|
func (v *Volume) readNeedle(n *needle.Needle) (int, error) {
|
||||||
nv, ok := v.nm.Get(n.Id)
|
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() {
|
if !ok || nv.Offset.IsZero() {
|
||||||
return -1, ErrorNotFound
|
return -1, ErrorNotFound
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if nv.Size == TombstoneFileSize {
|
if nv.Size == TombstoneFileSize {
|
||||||
return -1, errors.New("already deleted")
|
return -1, errors.New("already deleted")
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,6 @@ func (v *Volume) CommitCompact() error {
|
||||||
v.dataFileAccessLock.Lock()
|
v.dataFileAccessLock.Lock()
|
||||||
defer v.dataFileAccessLock.Unlock()
|
defer v.dataFileAccessLock.Unlock()
|
||||||
glog.V(3).Infof("Got volume %d committing lock...", v.Id)
|
glog.V(3).Infof("Got volume %d committing lock...", v.Id)
|
||||||
v.compactingWg.Add(1)
|
|
||||||
defer v.compactingWg.Done()
|
|
||||||
v.nm.Close()
|
v.nm.Close()
|
||||||
if err := v.dataFile.Close(); err != nil {
|
if err := v.dataFile.Close(); err != nil {
|
||||||
glog.V(0).Infof("fail to close volume %d", v.Id)
|
glog.V(0).Infof("fail to close volume %d", v.Id)
|
||||||
|
|
Loading…
Reference in a new issue