From: Tim Pierce Date: Tue, 22 Apr 2014 15:20:02 +0000 (-0400) Subject: Bug fix: GetBlock must report a CorruptError immediately. X-Git-Tag: 1.1.0~2596^2~26^2^2~13 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/b66ad0b212a80c117b5b344a715331962d0bfe2d Bug fix: GetBlock must report a CorruptError immediately. Refs #2620. --- diff --git a/services/keep/src/keep/keep.go b/services/keep/src/keep/keep.go index f13de44b79..e4a2675720 100644 --- a/services/keep/src/keep/keep.go +++ b/services/keep/src/keep/keep.go @@ -365,12 +365,18 @@ func GetBlock(hash string) ([]byte, error) { for _, vol := range KeepVolumes { uv := UnixVolume{vol} if buf, err := uv.Read(hash); err != nil { - if os.IsNotExist(err) { - // IsNotExist is an expected error. + // IsNotExist is an expected error and may be ignored. + // (If all volumes report IsNotExist, we return a NotFoundError) + // A CorruptError should be returned immediately. + // Any other errors should be logged but we continue trying to + // read. + switch { + case os.IsNotExist(err): continue - } else { + case err == CorruptError: + return nil, err + default: log.Printf("GetBlock: reading %s: %s\n", hash, err) - return buf, err } } else { // Success!