From 7ffe736d20f68cd0bd3d000649494e4550127c7d Mon Sep 17 00:00:00 2001 From: bingoohuang Date: Fri, 19 Feb 2021 15:59:55 +0800 Subject: [PATCH] renaming to ErrXyz --- weed/server/volume_server_handlers_read.go | 2 +- weed/storage/needle/needle_read_write.go | 4 ++-- weed/storage/store_ec.go | 4 ++-- weed/storage/volume_checking.go | 4 ++-- weed/storage/volume_read_write.go | 16 +++++++++------- weed/util/chunk_cache/chunk_cache_on_disk.go | 2 +- weed/util/chunk_cache/on_disk_cache_layer.go | 2 +- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go index 2db46ac9b..9604e7fe8 100644 --- a/weed/server/volume_server_handlers_read.go +++ b/weed/server/volume_server_handlers_read.go @@ -93,7 +93,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request) } else if hasEcVolume { count, err = vs.store.ReadEcShardNeedle(volumeId, n) } - if err != nil && err != storage.ErrorDeleted && r.FormValue("type") != "replicate" && hasVolume { + if err != nil && err != storage.ErrDeleted && r.FormValue("type") != "replicate" && hasVolume { glog.V(4).Infof("read needle: %v", err) // start to fix it from other replicas, if not deleted and hasVolume and is not a replicated request } diff --git a/weed/storage/needle/needle_read_write.go b/weed/storage/needle/needle_read_write.go index e758a6fee..4f8909faa 100644 --- a/weed/storage/needle/needle_read_write.go +++ b/weed/storage/needle/needle_read_write.go @@ -24,7 +24,7 @@ const ( TtlBytesLength = 2 ) -var ErrorSizeMismatch = errors.New("size mismatch") +var ErrSizeMismatch = errors.New("size mismatch") func (n *Needle) DiskSize(version Version) int64 { return GetActualSize(n.Size, version) @@ -173,7 +173,7 @@ func (n *Needle) ReadBytes(bytes []byte, offset int64, size Size, version Versio // cookie is not always passed in for this API. Use size to do preliminary checking. if OffsetSize == 4 && offset < int64(MaxPossibleVolumeSize) { glog.Errorf("entry not found1: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size) - return ErrorSizeMismatch + return ErrSizeMismatch } return fmt.Errorf("entry not found: offset %d found id %x size %d, expected size %d", offset, n.Id, n.Size, size) } diff --git a/weed/storage/store_ec.go b/weed/storage/store_ec.go index a9b6a8ff3..55b9a6fc6 100644 --- a/weed/storage/store_ec.go +++ b/weed/storage/store_ec.go @@ -130,7 +130,7 @@ func (s *Store) ReadEcShardNeedle(vid needle.VolumeId, n *needle.Needle) (int, e return 0, fmt.Errorf("locate in local ec volume: %v", err) } if size.IsDeleted() { - return 0, ErrorDeleted + return 0, ErrDeleted } glog.V(3).Infof("read ec volume %d offset %d size %d intervals:%+v", vid, offset.ToActualOffset(), size, intervals) @@ -143,7 +143,7 @@ func (s *Store) ReadEcShardNeedle(vid needle.VolumeId, n *needle.Needle) (int, e return 0, fmt.Errorf("ReadEcShardIntervals: %v", err) } if isDeleted { - return 0, ErrorDeleted + return 0, ErrDeleted } err = n.ReadBytes(bytes, offset.ToActualOffset(), size, localEcVolume.Version) diff --git a/weed/storage/volume_checking.go b/weed/storage/volume_checking.go index b76933083..f6e75a07c 100644 --- a/weed/storage/volume_checking.go +++ b/weed/storage/volume_checking.go @@ -30,7 +30,7 @@ func CheckAndFixVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAt healthyIndexSize = indexSize - int64(i)*NeedleMapEntrySize continue } - if err != ErrorSizeMismatch { + if err != ErrSizeMismatch { break } } @@ -94,7 +94,7 @@ func verifyNeedleIntegrity(datFile backend.BackendStorageFile, v needle.Version, return 0, fmt.Errorf("read %s at %d", datFile.Name(), offset) } if n.Size != size { - return 0, ErrorSizeMismatch + return 0, ErrSizeMismatch } if v == needle.Version3 { bytes := make([]byte, TimestampSize) diff --git a/weed/storage/volume_read_write.go b/weed/storage/volume_read_write.go index 07376bc88..7076e198b 100644 --- a/weed/storage/volume_read_write.go +++ b/weed/storage/volume_read_write.go @@ -15,9 +15,9 @@ import ( . "github.com/chrislusf/seaweedfs/weed/storage/types" ) -var ErrorNotFound = errors.New("not found") -var ErrorDeleted = errors.New("already deleted") -var ErrorSizeMismatch = errors.New("size mismatch") +var ErrNotFound = errors.New("not found") +var ErrDeleted = errors.New("already deleted") +var ErrSizeMismatch = errors.New("size mismatch") func (v *Volume) checkReadWriteError(err error) { if err == nil { @@ -289,7 +289,7 @@ func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption) (int, erro nv, ok := v.nm.Get(n.Id) if !ok || nv.Offset.IsZero() { - return -1, ErrorNotFound + return -1, ErrNotFound } readSize := nv.Size if readSize.IsDeleted() { @@ -297,14 +297,16 @@ func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption) (int, erro glog.V(3).Infof("reading deleted %s", n.String()) readSize = -readSize } else { - return -1, ErrorDeleted + return -1, ErrDeleted } } if readSize == 0 { return 0, nil } err := n.ReadData(v.DataBackend, nv.Offset.ToActualOffset(), readSize, v.Version()) - if err == needle.ErrorSizeMismatch && OffsetSize == 4 { + if err == needle.ErrSizeMismatch && OffsetSize == 4 { + // add special handling for .dat larger than 32GB, from git commit comment of + // 06c15ab3 Chris Lu on 2020/10/28 at 4:11 上 err = n.ReadData(v.DataBackend, nv.Offset.ToActualOffset()+int64(MaxPossibleVolumeSize), readSize, v.Version()) } v.checkReadWriteError(err) @@ -325,7 +327,7 @@ func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption) (int, erro if time.Now().Before(time.Unix(0, int64(n.AppendAtNs)).Add(time.Duration(ttlMinutes) * time.Minute)) { return bytesRead, nil } - return -1, ErrorNotFound + return -1, ErrNotFound } func (v *Volume) startWorker() { diff --git a/weed/util/chunk_cache/chunk_cache_on_disk.go b/weed/util/chunk_cache/chunk_cache_on_disk.go index d724e925e..c9f7356d6 100644 --- a/weed/util/chunk_cache/chunk_cache_on_disk.go +++ b/weed/util/chunk_cache/chunk_cache_on_disk.go @@ -104,7 +104,7 @@ func (v *ChunkCacheVolume) GetNeedle(key types.NeedleId) ([]byte, error) { nv, ok := v.nm.Get(key) if !ok { - return nil, storage.ErrorNotFound + return nil, storage.ErrNotFound } data := make([]byte, nv.Size) if readSize, readErr := v.DataBackend.ReadAt(data, nv.Offset.ToActualOffset()); readErr != nil { diff --git a/weed/util/chunk_cache/on_disk_cache_layer.go b/weed/util/chunk_cache/on_disk_cache_layer.go index eebd89798..2e8f998f7 100644 --- a/weed/util/chunk_cache/on_disk_cache_layer.go +++ b/weed/util/chunk_cache/on_disk_cache_layer.go @@ -66,7 +66,7 @@ func (c *OnDiskCacheLayer) getChunk(needleId types.NeedleId) (data []byte) { for _, diskCache := range c.diskCaches { data, err = diskCache.GetNeedle(needleId) - if err == storage.ErrorNotFound { + if err == storage.ErrNotFound { continue } if err != nil {