Fix create meta table fails for compatibility issue (#10703)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/10060/head^2
congqixia 2021-10-26 23:00:27 +08:00 committed by GitHub
parent dad09f5944
commit 555912f40e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -12,6 +12,7 @@
package rootcoord
import (
"bytes"
"fmt"
"path"
"strconv"
@ -137,6 +138,10 @@ func (mt *MetaTable) reloadFromKV() error {
}
for _, value := range values {
if bytes.Equal([]byte(value), suffixSnapshotTombstone) {
// backward compatibility, IndexMeta used to be in SnapshotKV
continue
}
proxyMeta := pb.ProxyMeta{}
err = proto.Unmarshal([]byte(value), &proxyMeta)
if err != nil {
@ -165,6 +170,10 @@ func (mt *MetaTable) reloadFromKV() error {
return err
}
for _, value := range values {
if bytes.Equal([]byte(value), suffixSnapshotTombstone) {
// backward compatibility, IndexMeta used to be in SnapshotKV
continue
}
segmentIndexInfo := pb.SegmentIndexInfo{}
err = proto.Unmarshal([]byte(value), &segmentIndexInfo)
if err != nil {
@ -197,6 +206,10 @@ func (mt *MetaTable) reloadFromKV() error {
return err
}
for _, value := range values {
if bytes.Equal([]byte(value), suffixSnapshotTombstone) {
// backward compatibility, IndexMeta used to be in SnapshotKV
continue
}
meta := pb.IndexInfo{}
err = proto.Unmarshal([]byte(value), &meta)
if err != nil {

View File

@ -14,12 +14,14 @@ import (
"errors"
"fmt"
"math/rand"
"path"
"testing"
"time"
"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus/internal/kv"
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
memkv "github.com/milvus-io/milvus/internal/kv/mem"
"github.com/milvus-io/milvus/internal/proto/commonpb"
pb "github.com/milvus-io/milvus/internal/proto/etcdpb"
"github.com/milvus-io/milvus/internal/proto/schemapb"
@ -1231,3 +1233,27 @@ func TestMetaWithTimestamp(t *testing.T) {
_, err = mt.GetPartitionByName(2, partName2, tsoStart)
assert.NotNil(t, err)
}
func TestFixIssue10540(t *testing.T) {
rand.Seed(time.Now().UnixNano())
randVal := rand.Int()
Params.Init()
rootPath := fmt.Sprintf("/test/meta/%d", randVal)
etcdCli, err := clientv3.New(clientv3.Config{Endpoints: Params.EtcdEndpoints})
assert.Nil(t, err)
defer etcdCli.Close()
skv, err := newMetaSnapshot(etcdCli, rootPath, TimestampPrefix, 7)
assert.Nil(t, err)
assert.NotNil(t, skv)
//txnKV := etcdkv.NewEtcdKVWithClient(etcdCli, rootPath)
txnKV := memkv.NewMemoryKV()
// compose rc7 legace tombstone cases
txnKV.Save(path.Join(ProxyMetaPrefix, "1"), string(suffixSnapshotTombstone))
txnKV.Save(path.Join(SegmentIndexMetaPrefix, "2"), string(suffixSnapshotTombstone))
txnKV.Save(path.Join(IndexMetaPrefix, "3"), string(suffixSnapshotTombstone))
_, err = NewMetaTable(txnKV, skv)
assert.Nil(t, err)
}