mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-24 19:19:11 +08:00
Do not vacuum memory mapped files
This commit is contained in:
parent
0123c7a898
commit
9a459d984b
@ -8,6 +8,7 @@ import (
|
||||
"github.com/joeslay/seaweedfs/weed/glog"
|
||||
"github.com/joeslay/seaweedfs/weed/stats"
|
||||
idx2 "github.com/joeslay/seaweedfs/weed/storage/idx"
|
||||
"github.com/joeslay/seaweedfs/weed/storage/memory_map"
|
||||
"github.com/joeslay/seaweedfs/weed/storage/needle"
|
||||
"github.com/joeslay/seaweedfs/weed/storage/needle_map"
|
||||
. "github.com/joeslay/seaweedfs/weed/storage/types"
|
||||
@ -22,6 +23,9 @@ func (v *Volume) garbageLevel() float64 {
|
||||
}
|
||||
|
||||
func (v *Volume) Compact(preallocate int64, compactionBytePerSecond int64) error {
|
||||
|
||||
_, exists := memory_map.FileMemoryMap[v.dataFile.Name()]
|
||||
if !exists { //it makes no sense to compact in memory
|
||||
glog.V(3).Infof("Compacting volume %d ...", v.Id)
|
||||
//no need to lock for copy on write
|
||||
//v.accessLock.Lock()
|
||||
@ -37,9 +41,15 @@ func (v *Volume) Compact(preallocate int64, compactionBytePerSecond int64) error
|
||||
v.lastCompactRevision = v.SuperBlock.CompactionRevision
|
||||
glog.V(3).Infof("creating copies for volume %d ,last offset %d...", v.Id, v.lastCompactIndexOffset)
|
||||
return v.copyDataAndGenerateIndexFile(filePath+".cpd", filePath+".cpx", preallocate, compactionBytePerSecond)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Volume) Compact2() error {
|
||||
_, exists := memory_map.FileMemoryMap[v.dataFile.Name()]
|
||||
if !exists { //it makes no sense to compact in memory
|
||||
|
||||
glog.V(3).Infof("Compact2 volume %d ...", v.Id)
|
||||
|
||||
v.isCompacting = true
|
||||
@ -50,9 +60,14 @@ func (v *Volume) Compact2() error {
|
||||
filePath := v.FileName()
|
||||
glog.V(3).Infof("creating copies for volume %d ...", v.Id)
|
||||
return v.copyDataBasedOnIndexFile(filePath+".cpd", filePath+".cpx")
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Volume) CommitCompact() error {
|
||||
_, exists := memory_map.FileMemoryMap[v.dataFile.Name()]
|
||||
if !exists { //it makes no sense to compact in memory
|
||||
glog.V(0).Infof("Committing volume %d vacuuming...", v.Id)
|
||||
|
||||
v.isCompacting = true
|
||||
@ -102,6 +117,7 @@ func (v *Volume) CommitCompact() error {
|
||||
if e = v.load(true, false, v.needleMapKind, 0); e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user