mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 11:29:48 +08:00
Fix datanode always retries to load stats even file corrupted (#25012)
Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
parent
73b7cf5df4
commit
8bc5282eb3
@ -24,6 +24,7 @@ import (
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
||||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/log"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -254,7 +255,10 @@ func (sr *StatsReader) GetPrimaryKeyStats() (*PrimaryKeyStats, error) {
|
||||
stats := &PrimaryKeyStats{}
|
||||
err := json.Unmarshal(sr.buffer, &stats)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, merr.WrapErrParameterInvalid(
|
||||
"valid JSON",
|
||||
string(sr.buffer),
|
||||
err.Error())
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
@ -265,7 +269,10 @@ func (sr *StatsReader) GetPrimaryKeyStatsList() ([]*PrimaryKeyStats, error) {
|
||||
stats := []*PrimaryKeyStats{}
|
||||
err := json.Unmarshal(sr.buffer, &stats)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, merr.WrapErrParameterInvalid(
|
||||
"valid JSON",
|
||||
string(sr.buffer),
|
||||
err.Error())
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
|
||||
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
||||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
)
|
||||
|
||||
func TestStatsWriter_Int64PrimaryKey(t *testing.T) {
|
||||
@ -155,3 +156,12 @@ func TestStatsWriter_UpgradePrimaryKey(t *testing.T) {
|
||||
assert.True(t, unmarshaledStats.BF.Test(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeserializeStatsFailed(t *testing.T) {
|
||||
blob := &Blob{
|
||||
Value: []byte("abc"),
|
||||
}
|
||||
|
||||
_, err := DeserializeStatsList(blob)
|
||||
assert.ErrorIs(t, err, merr.ErrParameterInvalid)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user