未验证 提交 76523b31 编写于 作者: X xing.zhao 提交者: GitHub

Fix bug #17403 by double check collmeta prefix and alias prefix (#17548)

Signed-off-by: Nxingzhao <xing.zhao@zilliz.com>
Co-authored-by: Nxingzhao <xing.zhao@zilliz.com>
上级 e825215c
...@@ -151,6 +151,19 @@ func (mt *MetaTable) reloadFromKV() error { ...@@ -151,6 +151,19 @@ func (mt *MetaTable) reloadFromKV() error {
mt.proxyID2Meta[proxyMeta.ID] = proxyMeta 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) _, values, err = mt.snapshot.LoadWithPrefix(CollectionMetaPrefix, 0)
if err != nil { if err != nil {
return err return err
...@@ -162,6 +175,9 @@ func (mt *MetaTable) reloadFromKV() error { ...@@ -162,6 +175,9 @@ func (mt *MetaTable) reloadFromKV() error {
if err != nil { if err != nil {
return fmt.Errorf("rootcoord Unmarshal pb.CollectionInfo err:%w", err) 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.collID2Meta[collInfo.ID] = collInfo
mt.collName2ID[collInfo.Schema.Name] = collInfo.ID mt.collName2ID[collInfo.Schema.Name] = collInfo.ID
} }
...@@ -219,19 +235,6 @@ func (mt *MetaTable) reloadFromKV() error { ...@@ -219,19 +235,6 @@ func (mt *MetaTable) reloadFromKV() error {
mt.indexID2Meta[meta.IndexID] = meta 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") log.Debug("reload meta table from KV successfully")
return nil return nil
} }
......
...@@ -344,6 +344,18 @@ func TestMetaTable(t *testing.T) { ...@@ -344,6 +344,18 @@ func TestMetaTable(t *testing.T) {
assert.Nil(t, err) 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) wg.Add(1)
t.Run("add partition", func(t *testing.T) { t.Run("add partition", func(t *testing.T) {
defer wg.Done() defer wg.Done()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册