mirror of https://github.com/milvus-io/milvus.git
Fix drop index with large txn exceed etcd limit (#25622)
Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>pull/26448/head
parent
7e3323a518
commit
f9c47bbc1e
|
@ -618,8 +618,19 @@ func (kc *Catalog) AlterIndexes(ctx context.Context, indexes []*model.Index) err
|
|||
}
|
||||
|
||||
kvs[key] = string(value)
|
||||
// TODO when we have better txn kv we should make this as a transaction
|
||||
if len(kvs) >= 64 {
|
||||
err = kc.MetaKv.MultiSave(kvs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
kvs = make(map[string]string)
|
||||
}
|
||||
}
|
||||
return kc.MetaKv.MultiSave(kvs)
|
||||
if len(kvs) != 0 {
|
||||
return kc.MetaKv.MultiSave(kvs)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (kc *Catalog) DropIndex(ctx context.Context, collID typeutil.UniqueID, dropIdxID typeutil.UniqueID) error {
|
||||
|
|
|
@ -854,6 +854,41 @@ func TestCatalog_AlterIndexes(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestCatalog_AlterSegmentMultiIndexes(t *testing.T) {
|
||||
segIdx := make([]*model.Index, 100)
|
||||
for i := 0; i < 100; i++ {
|
||||
segIdx[i] = &model.Index{
|
||||
CollectionID: 0,
|
||||
FieldID: 0,
|
||||
IndexID: int64(i),
|
||||
IndexName: "",
|
||||
IsDeleted: false,
|
||||
CreateTime: 0,
|
||||
TypeParams: nil,
|
||||
IndexParams: nil,
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("batchAdd", func(t *testing.T) {
|
||||
metakv := mocks.NewMetaKv(t)
|
||||
|
||||
metakv.EXPECT().MultiSave(mock.Anything).RunAndReturn(func(m map[string]string) error {
|
||||
if len(m) > 64 {
|
||||
return errors.New("fail")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
metakv.EXPECT().MultiSave(mock.Anything).Return(nil)
|
||||
catalog := &Catalog{
|
||||
MetaKv: metakv,
|
||||
}
|
||||
err := catalog.AlterIndexes(context.Background(), segIdx)
|
||||
fmt.Println(err)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestCatalog_DropIndex(t *testing.T) {
|
||||
t.Run("success", func(t *testing.T) {
|
||||
metakv := mocks.NewMetaKv(t)
|
||||
|
|
Loading…
Reference in New Issue