mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 17:37:23 +08:00
volume: compaction can cause readonly volumes
address https://github.com/chrislusf/seaweedfs/issues/1233
This commit is contained in:
@@ -145,7 +145,7 @@ func (s *Store) VolumeInfos() []*VolumeInfo {
|
||||
FileCount: int(v.FileCount()),
|
||||
DeleteCount: int(v.DeletedCount()),
|
||||
DeletedByteCount: v.DeletedSize(),
|
||||
ReadOnly: v.noWriteOrDelete || v.noWriteCanDelete,
|
||||
ReadOnly: v.IsReadOnly(),
|
||||
Ttl: v.Ttl,
|
||||
CompactRevision: uint32(v.CompactionRevision),
|
||||
}
|
||||
@@ -229,7 +229,7 @@ func (s *Store) Close() {
|
||||
|
||||
func (s *Store) WriteVolumeNeedle(i needle.VolumeId, n *needle.Needle) (isUnchanged bool, err error) {
|
||||
if v := s.findVolume(i); v != nil {
|
||||
if v.noWriteOrDelete || v.noWriteCanDelete {
|
||||
if v.v.IsReadOnly() {
|
||||
err = fmt.Errorf("volume %d is read only", i)
|
||||
return
|
||||
}
|
||||
|
@@ -215,7 +215,7 @@ func (v *Volume) ToVolumeInformationMessage() *master_pb.VolumeInformationMessag
|
||||
FileCount: v.FileCount(),
|
||||
DeleteCount: v.DeletedCount(),
|
||||
DeletedByteCount: v.DeletedSize(),
|
||||
ReadOnly: v.noWriteOrDelete || v.noWriteCanDelete,
|
||||
ReadOnly: v.IsReadOnly(),
|
||||
ReplicaPlacement: uint32(v.ReplicaPlacement.Byte()),
|
||||
Version: uint32(v.Version()),
|
||||
Ttl: v.Ttl.ToUint32(),
|
||||
@@ -237,3 +237,7 @@ func (v *Volume) RemoteStorageNameKey() (storageName, storageKey string) {
|
||||
}
|
||||
return v.volumeInfo.GetFiles()[0].BackendName(), v.volumeInfo.GetFiles()[0].GetKey()
|
||||
}
|
||||
|
||||
func (v *Volume) IsReadOnly() bool {
|
||||
return v.noWriteOrDelete || v.noWriteCanDelete
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ func readIndexEntryAtOffset(indexFile *os.File, offset int64) (bytes []byte, err
|
||||
func verifyNeedleIntegrity(datFile backend.BackendStorageFile, v needle.Version, offset int64, key NeedleId, size uint32) (lastAppendAtNs uint64, err error) {
|
||||
n := new(needle.Needle)
|
||||
if err = n.ReadData(datFile, offset, size, v); err != nil {
|
||||
return n.AppendAtNs, err
|
||||
return n.AppendAtNs, fmt.Errorf("read data [%d,%d) : %v", offset, offset+int64(size), err)
|
||||
}
|
||||
if n.Id != key {
|
||||
return n.AppendAtNs, fmt.Errorf("index key %#x does not match needle's Id %#x", key, n.Id)
|
||||
|
@@ -94,7 +94,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
||||
glog.V(0).Infof("volumeDataIntegrityChecking failed %v", err)
|
||||
}
|
||||
|
||||
if v.noWriteOrDelete || v.noWriteCanDelete {
|
||||
if v.IsReadOnly() {
|
||||
if v.nm, err = NewSortedFileNeedleMap(fileName, indexFile); err != nil {
|
||||
glog.V(0).Infof("loading sorted db %s error: %v", fileName+".sdx", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user