ReadNeedleMeta recovery panic occurred (#3883)

ReadNeedleMeta panic occurred
https://github.com/seaweedfs/seaweedfs/issues/3882
This commit is contained in:
Konstantin Lebedev 2022-10-24 02:00:28 +05:00 committed by GitHub
parent e3ea544d40
commit 452202f35b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
package needle package needle
import ( import (
"fmt"
"github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/storage/backend" "github.com/seaweedfs/seaweedfs/weed/storage/backend"
. "github.com/seaweedfs/seaweedfs/weed/storage/types" . "github.com/seaweedfs/seaweedfs/weed/storage/types"
@ -30,6 +31,11 @@ func (n *Needle) ReadNeedleData(r backend.BackendStorageFile, volumeOffset int64
// ReadNeedleMeta fills all metadata except the n.Data // ReadNeedleMeta fills all metadata except the n.Data
func (n *Needle) ReadNeedleMeta(r backend.BackendStorageFile, offset int64, size Size, version Version) (err error) { func (n *Needle) ReadNeedleMeta(r backend.BackendStorageFile, offset int64, size Size, version Version) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("panic occurred: %+v", r)
}
}()
bytes := make([]byte, NeedleHeaderSize+DataSizeSize) bytes := make([]byte, NeedleHeaderSize+DataSizeSize)