Fix bug by double check collmeta prefix and alias prefix ()

Signed-off-by: xingzhao <xing.zhao@zilliz.com>

Co-authored-by: xingzhao <xing.zhao@zilliz.com>
pull/17544/head
xing.zhao 2022-06-15 19:14:10 +08:00 committed by GitHub
parent e825215c44
commit 76523b313b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 13 deletions

View File

@ -151,6 +151,19 @@ func (mt *MetaTable) reloadFromKV() error {
mt.proxyID2Meta[proxyMeta.ID] = proxyMeta
}
_, values, err = mt.snapshot.LoadWithPrefix(CollectionAliasMetaPrefix, 0)
if err != nil {
return err
}
for _, value := range values {
aliasInfo := pb.CollectionInfo{}
err = proto.Unmarshal([]byte(value), &aliasInfo)
if err != nil {
return fmt.Errorf("rootcoord Unmarshal pb.AliasInfo err:%w", err)
}
mt.collAlias2ID[aliasInfo.Schema.Name] = aliasInfo.ID
}
_, values, err = mt.snapshot.LoadWithPrefix(CollectionMetaPrefix, 0)
if err != nil {
return err
@ -162,6 +175,9 @@ func (mt *MetaTable) reloadFromKV() error {
if err != nil {
return fmt.Errorf("rootcoord Unmarshal pb.CollectionInfo err:%w", err)
}
if _, ok := mt.collAlias2ID[collInfo.Schema.Name]; ok {
continue
}
mt.collID2Meta[collInfo.ID] = collInfo
mt.collName2ID[collInfo.Schema.Name] = collInfo.ID
}
@ -219,19 +235,6 @@ func (mt *MetaTable) reloadFromKV() error {
mt.indexID2Meta[meta.IndexID] = meta
}
_, values, err = mt.snapshot.LoadWithPrefix(CollectionAliasMetaPrefix, 0)
if err != nil {
return err
}
for _, value := range values {
aliasInfo := pb.CollectionInfo{}
err = proto.Unmarshal([]byte(value), &aliasInfo)
if err != nil {
return fmt.Errorf("rootcoord Unmarshal pb.AliasInfo err:%w", err)
}
mt.collAlias2ID[aliasInfo.Schema.Name] = aliasInfo.ID
}
log.Debug("reload meta table from KV successfully")
return nil
}

View File

@ -344,6 +344,18 @@ func TestMetaTable(t *testing.T) {
assert.Nil(t, err)
})
wg.Add(1)
t.Run("not load alias when load collection meta", func(t *testing.T) {
defer wg.Done()
ts := ftso()
err = mt.AddAlias(aliasName1, collName, ts)
assert.Nil(t, err)
err = mt.reloadFromKV()
assert.Nil(t, err)
_, ok := mt.collName2ID[aliasName1]
assert.False(t, ok)
})
wg.Add(1)
t.Run("add partition", func(t *testing.T) {
defer wg.Done()