mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix errors with frozen volume loading
This commit is contained in:
parent
f262fed197
commit
92ffba2ab9
|
@ -178,7 +178,11 @@ func (nm *NeedleMap) Put(key uint64, offset uint32, size uint32) (int, error) {
|
||||||
return nm.indexFile.Write(nm.bytes)
|
return nm.indexFile.Write(nm.bytes)
|
||||||
}
|
}
|
||||||
func (nm *NeedleMap) Get(key uint64) (element *NeedleValue, ok bool) {
|
func (nm *NeedleMap) Get(key uint64) (element *NeedleValue, ok bool) {
|
||||||
element, ok = nm.m.Get(Key(key))
|
if nm.m != nil {
|
||||||
|
element, ok = nm.m.Get(Key(key))
|
||||||
|
} else {
|
||||||
|
element, ok = nm.fm.Get(Key(key))
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (nm *NeedleMap) Delete(key uint64) error {
|
func (nm *NeedleMap) Delete(key uint64) error {
|
||||||
|
@ -202,5 +206,8 @@ func (nm *NeedleMap) ContentSize() uint64 {
|
||||||
|
|
||||||
// iterate through all needles using the iterator function
|
// iterate through all needles using the iterator function
|
||||||
func (nm *NeedleMap) Walk(pedestrian func(*NeedleValue) error) (err error) {
|
func (nm *NeedleMap) Walk(pedestrian func(*NeedleValue) error) (err error) {
|
||||||
return nm.m.Walk(pedestrian)
|
if nm.m != nil {
|
||||||
|
return nm.m.Walk(pedestrian)
|
||||||
|
}
|
||||||
|
return nm.fm.Walk(pedestrian)
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,9 @@ func (s *Store) loadExistingVolumes() {
|
||||||
if s.volumes[vid] == nil {
|
if s.volumes[vid] == nil {
|
||||||
if v, e := NewVolume(s.dir, vid, CopyNil); e == nil {
|
if v, e := NewVolume(s.dir, vid, CopyNil); e == nil {
|
||||||
s.volumes[vid] = v
|
s.volumes[vid] = v
|
||||||
log.Println("In dir", s.dir, "read volume =", vid, "replicationType =", v.replicaType, "version =", v.version, "size =", v.Size())
|
log.Println("In dir", s.dir, "read volume =", vid, "replicationType =", v.replicaType, "version =", v.version, "size =", v.Size(), "frozen?", !v.IsWritable())
|
||||||
|
} else {
|
||||||
|
log.Println("ERROR loading volume", vid, "in dir", s.dir, ":", e.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,14 @@ func (v *Volume) load() error {
|
||||||
fileName := path.Join(v.dir, v.Id.String())
|
fileName := path.Join(v.dir, v.Id.String())
|
||||||
v.dataFile, e = os.OpenFile(fileName+".dat", os.O_RDWR|os.O_CREATE, 0644)
|
v.dataFile, e = os.OpenFile(fileName+".dat", os.O_RDWR|os.O_CREATE, 0644)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return fmt.Errorf("cannot create Volume Data %s.dat: %s", fileName, e)
|
if os.IsPermission(e) {
|
||||||
|
if util.FileExists(fileName + ".cdb") {
|
||||||
|
v.dataFile, e = os.Open(fileName + ".dat")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if e != nil {
|
||||||
|
return fmt.Errorf("cannot create Volume Data %s.dat: %s", fileName, e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if v.replicaType == CopyNil {
|
if v.replicaType == CopyNil {
|
||||||
if e = v.readSuperBlock(); e != nil {
|
if e = v.readSuperBlock(); e != nil {
|
||||||
|
|
Loading…
Reference in a new issue