Skip to content

Commit

Permalink
Fix create meta table fails for compatibility issue (#10703)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia authored Oct 26, 2021
1 parent dad09f5 commit 555912f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/rootcoord/meta_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package rootcoord

import (
"bytes"
"fmt"
"path"
"strconv"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
26 changes: 26 additions & 0 deletions internal/rootcoord/meta_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

0 comments on commit 555912f

Please sign in to comment.