mirror of https://github.com/milvus-io/milvus.git
Cherry-pick from master pr: #41242 Related to #41241 --------- Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/41346/head
parent
55b37c3bb6
commit
f4c541e94a
|
@ -654,8 +654,21 @@ func (kc *Catalog) alterModifyCollection(ctx context.Context, oldColl *model.Col
|
|||
return err
|
||||
}
|
||||
saves := map[string]string{newKey: string(value)}
|
||||
// no default aliases will be created.
|
||||
// save fields info to new path.
|
||||
for _, field := range newColl.Fields {
|
||||
k := BuildFieldKey(newColl.CollectionID, field.FieldID)
|
||||
fieldInfo := model.MarshalFieldModel(field)
|
||||
v, err := proto.Marshal(fieldInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
saves[k] = string(v)
|
||||
}
|
||||
if oldKey == newKey {
|
||||
return kc.Snapshot.Save(ctx, newKey, string(value), ts)
|
||||
return etcd.SaveByBatchWithLimit(saves, util.MaxEtcdTxnNum/2, func(partialKvs map[string]string) error {
|
||||
return kc.Snapshot.MultiSave(ctx, partialKvs, ts)
|
||||
})
|
||||
}
|
||||
return kc.Snapshot.MultiSaveAndRemove(ctx, saves, []string{oldKey}, ts)
|
||||
}
|
||||
|
|
|
@ -1036,6 +1036,12 @@ func TestCatalog_AlterCollection(t *testing.T) {
|
|||
kvs[key] = value
|
||||
return nil
|
||||
}
|
||||
snapshot.MultiSaveFunc = func(ctx context.Context, saveKvs map[string]string, _ typeutil.Timestamp) error {
|
||||
for k, v := range saveKvs {
|
||||
kvs[k] = v
|
||||
}
|
||||
return nil
|
||||
}
|
||||
kc := NewCatalog(nil, snapshot).(*Catalog)
|
||||
ctx := context.Background()
|
||||
var collectionID int64 = 1
|
||||
|
|
Loading…
Reference in New Issue