Get index status based on segment generation time (#17659)

Signed-off-by: Cai.Zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2022-06-21 18:44:12 +08:00 committed by GitHub
parent e43f487f02
commit 4efdd0929c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 187 additions and 74 deletions

View File

@ -16,6 +16,7 @@ message IndexInfo {
int64 indexID = 2; int64 indexID = 2;
repeated common.KeyValuePair index_params = 3; repeated common.KeyValuePair index_params = 3;
bool deleted = 4; bool deleted = 4;
uint64 create_time = 5;
} }
message FieldIndexInfo{ message FieldIndexInfo{
@ -46,7 +47,7 @@ message SegmentIndexInfo {
int64 indexID = 5; int64 indexID = 5;
int64 buildID = 6; int64 buildID = 6;
bool enable_index = 7; bool enable_index = 7;
bool by_auto_flush = 8; uint64 create_time = 8;
} }
message CollectionMeta { message CollectionMeta {

View File

@ -82,6 +82,7 @@ type IndexInfo struct {
IndexID int64 `protobuf:"varint,2,opt,name=indexID,proto3" json:"indexID,omitempty"` IndexID int64 `protobuf:"varint,2,opt,name=indexID,proto3" json:"indexID,omitempty"`
IndexParams []*commonpb.KeyValuePair `protobuf:"bytes,3,rep,name=index_params,json=indexParams,proto3" json:"index_params,omitempty"` IndexParams []*commonpb.KeyValuePair `protobuf:"bytes,3,rep,name=index_params,json=indexParams,proto3" json:"index_params,omitempty"`
Deleted bool `protobuf:"varint,4,opt,name=deleted,proto3" json:"deleted,omitempty"` Deleted bool `protobuf:"varint,4,opt,name=deleted,proto3" json:"deleted,omitempty"`
CreateTime uint64 `protobuf:"varint,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -140,6 +141,13 @@ func (m *IndexInfo) GetDeleted() bool {
return false return false
} }
func (m *IndexInfo) GetCreateTime() uint64 {
if m != nil {
return m.CreateTime
}
return 0
}
type FieldIndexInfo struct { type FieldIndexInfo struct {
FiledID int64 `protobuf:"varint,1,opt,name=filedID,proto3" json:"filedID,omitempty"` FiledID int64 `protobuf:"varint,1,opt,name=filedID,proto3" json:"filedID,omitempty"`
IndexID int64 `protobuf:"varint,2,opt,name=indexID,proto3" json:"indexID,omitempty"` IndexID int64 `protobuf:"varint,2,opt,name=indexID,proto3" json:"indexID,omitempty"`
@ -322,7 +330,7 @@ type SegmentIndexInfo struct {
IndexID int64 `protobuf:"varint,5,opt,name=indexID,proto3" json:"indexID,omitempty"` IndexID int64 `protobuf:"varint,5,opt,name=indexID,proto3" json:"indexID,omitempty"`
BuildID int64 `protobuf:"varint,6,opt,name=buildID,proto3" json:"buildID,omitempty"` BuildID int64 `protobuf:"varint,6,opt,name=buildID,proto3" json:"buildID,omitempty"`
EnableIndex bool `protobuf:"varint,7,opt,name=enable_index,json=enableIndex,proto3" json:"enable_index,omitempty"` EnableIndex bool `protobuf:"varint,7,opt,name=enable_index,json=enableIndex,proto3" json:"enable_index,omitempty"`
ByAutoFlush bool `protobuf:"varint,8,opt,name=by_auto_flush,json=byAutoFlush,proto3" json:"by_auto_flush,omitempty"` CreateTime uint64 `protobuf:"varint,8,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -402,11 +410,11 @@ func (m *SegmentIndexInfo) GetEnableIndex() bool {
return false return false
} }
func (m *SegmentIndexInfo) GetByAutoFlush() bool { func (m *SegmentIndexInfo) GetCreateTime() uint64 {
if m != nil { if m != nil {
return m.ByAutoFlush return m.CreateTime
} }
return false return 0
} }
type CollectionMeta struct { type CollectionMeta struct {
@ -500,52 +508,52 @@ func init() {
func init() { proto.RegisterFile("etcd_meta.proto", fileDescriptor_975d306d62b73e88) } func init() { proto.RegisterFile("etcd_meta.proto", fileDescriptor_975d306d62b73e88) }
var fileDescriptor_975d306d62b73e88 = []byte{ var fileDescriptor_975d306d62b73e88 = []byte{
// 751 bytes of a gzipped FileDescriptorProto // 737 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4d, 0x6b, 0xeb, 0x46, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4b, 0x6b, 0xeb, 0x46,
0x14, 0x45, 0x96, 0x63, 0x47, 0xd7, 0x8a, 0x5f, 0x32, 0xfd, 0x60, 0x08, 0x69, 0xab, 0x27, 0x78, 0x14, 0x46, 0x96, 0x1f, 0xd1, 0xb1, 0xae, 0x6f, 0x32, 0x7d, 0x30, 0x84, 0xb4, 0xd5, 0x35, 0xdc,
0x45, 0x50, 0x6a, 0xd3, 0xbc, 0xd2, 0x5d, 0xa1, 0xaf, 0x16, 0x01, 0xd3, 0xf6, 0x61, 0x26, 0xa1, 0x22, 0x28, 0xb5, 0x69, 0x6e, 0xe9, 0xae, 0xd0, 0xd6, 0x22, 0x60, 0xda, 0x06, 0x33, 0x09, 0x5d,
0x8b, 0x6e, 0xc4, 0x58, 0xba, 0xb6, 0x07, 0xf4, 0x61, 0x34, 0xa3, 0x10, 0xef, 0xba, 0xef, 0xdf, 0x74, 0x23, 0xc6, 0xd2, 0xb1, 0x3d, 0xa0, 0x87, 0xd1, 0x8c, 0x42, 0xbc, 0xeb, 0xb2, 0x7f, 0xac,
0xe8, 0xbf, 0xeb, 0x7f, 0x28, 0x45, 0x33, 0x92, 0xfc, 0x91, 0x64, 0xd9, 0x9d, 0xcf, 0x99, 0x7b, 0xbf, 0xa6, 0xff, 0xa1, 0x14, 0xcd, 0x48, 0xf2, 0x2b, 0x59, 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6, 0x3c, 0x9d, 0xea, 0xcd, 0xa6, 0x75, 0x6a, 0xb7, 0xcb, 0xe5, 0x40, 0xa3, 0x6b, 0xf4, 0xe1, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x2d, 0xaa, 0x13, 0x88, 0x06, 0x00,
0xf7, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x19, 0xa3, 0x49, 0xe3, 0x6a, 0x06, 0x00, 0x00, 0x00,
} }

View File

@ -953,10 +953,12 @@ func (mt *MetaTable) GetInitBuildIDs(collName, indexName string) ([]UniqueID, er
} }
var indexID typeutil.UniqueID var indexID typeutil.UniqueID
var indexIDCreateTS uint64
for _, info := range collMeta.FieldIndexes { for _, info := range collMeta.FieldIndexes {
idxMeta, ok := mt.indexID2Meta[info.IndexID] idxMeta, ok := mt.indexID2Meta[info.IndexID]
if ok && idxMeta.IndexName == indexName { if ok && idxMeta.IndexName == indexName {
indexID = info.IndexID indexID = info.IndexID
indexIDCreateTS = idxMeta.CreateTime
break break
} }
} }
@ -970,7 +972,7 @@ func (mt *MetaTable) GetInitBuildIDs(collName, indexName string) ([]UniqueID, er
initBuildIDs := make([]UniqueID, 0) initBuildIDs := make([]UniqueID, 0)
for _, indexID2Info := range mt.segID2IndexMeta { for _, indexID2Info := range mt.segID2IndexMeta {
segIndexInfo, ok := indexID2Info[indexID] segIndexInfo, ok := indexID2Info[indexID]
if ok && segIndexInfo.EnableIndex && !segIndexInfo.ByAutoFlush { if ok && segIndexInfo.EnableIndex && segIndexInfo.CreateTime <= indexIDCreateTS {
initBuildIDs = append(initBuildIDs, segIndexInfo.BuildID) initBuildIDs = append(initBuildIDs, segIndexInfo.BuildID)
} }
} }
@ -1282,21 +1284,21 @@ func (mt *MetaTable) checkFieldCanBeIndexed(collMeta pb.CollectionInfo, fieldSch
return nil return nil
} }
func (mt *MetaTable) checkFieldIndexDuplicate(collMeta pb.CollectionInfo, fieldSchema schemapb.FieldSchema, idxInfo *pb.IndexInfo) (duplicate bool, err error) { func (mt *MetaTable) checkFieldIndexDuplicate(collMeta pb.CollectionInfo, fieldSchema schemapb.FieldSchema, idxInfo *pb.IndexInfo) (duplicate bool, dupIdxInfo *pb.IndexInfo, err error) {
for _, f := range collMeta.FieldIndexes { for _, f := range collMeta.FieldIndexes {
if info, ok := mt.indexID2Meta[f.IndexID]; ok && !info.GetDeleted() { if info, ok := mt.indexID2Meta[f.IndexID]; ok && !info.GetDeleted() {
if info.IndexName == idxInfo.IndexName { if info.IndexName == idxInfo.IndexName {
// the index name must be different for different indexes // the index name must be different for different indexes
if f.FiledID != fieldSchema.FieldID || !EqualKeyPairArray(info.IndexParams, idxInfo.IndexParams) { if f.FiledID != fieldSchema.FieldID || !EqualKeyPairArray(info.IndexParams, idxInfo.IndexParams) {
return false, fmt.Errorf("index already exists, collection: %s, field: %s, index: %s", collMeta.GetSchema().GetName(), fieldSchema.GetName(), idxInfo.GetIndexName()) return false, nil, fmt.Errorf("index already exists, collection: %s, field: %s, index: %s", collMeta.GetSchema().GetName(), fieldSchema.GetName(), idxInfo.GetIndexName())
} }
// same index name, index params, and fieldId // same index name, index params, and fieldId
return true, nil return true, proto.Clone(&info).(*pb.IndexInfo), nil
} }
} }
} }
return false, nil return false, nil, nil
} }
// GetNotIndexedSegments return segment ids which have no index // GetNotIndexedSegments return segment ids which have no index
@ -1335,7 +1337,7 @@ func (mt *MetaTable) GetNotIndexedSegments(collName string, fieldName string, id
return nil, schemapb.FieldSchema{}, err return nil, schemapb.FieldSchema{}, err
} }
dupIdx, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo) dupIdx, dupIdxInfo, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo)
if err != nil { if err != nil {
// error here if index already exists. // error here if index already exists.
return nil, fieldSchema, err return nil, fieldSchema, err
@ -1374,6 +1376,25 @@ func (mt *MetaTable) GetNotIndexedSegments(collName string, fieldName string, id
mt.collID2Meta[collMeta.ID] = collMeta mt.collID2Meta[collMeta.ID] = collMeta
mt.indexID2Meta[idx.IndexID] = *idxInfo mt.indexID2Meta[idx.IndexID] = *idxInfo
} else {
log.Info("index has been created, update timestamp for IndexID", zap.Int64("indexID", dupIdxInfo.IndexID))
// just update create time for IndexID
dupIdxInfo.CreateTime = idxInfo.CreateTime
k := fmt.Sprintf("%s/%d/%d", IndexMetaPrefix, collMeta.ID, dupIdxInfo.IndexID)
v, err := proto.Marshal(dupIdxInfo)
if err != nil {
log.Error("MetaTable GetNotIndexedSegments Marshal idxInfo fail",
zap.String("key", k), zap.Error(err))
return nil, schemapb.FieldSchema{}, fmt.Errorf("metaTable GetNotIndexedSegments Marshal idxInfo fail key:%s, err:%w", k, err)
}
meta := map[string]string{k: string(v)}
err = mt.txn.MultiSave(meta)
if err != nil {
log.Error("TxnKV MultiSave fail", zap.Error(err))
panic("TxnKV MultiSave fail")
}
mt.indexID2Meta[dupIdxInfo.IndexID] = *dupIdxInfo
} }
rstID := make([]typeutil.UniqueID, 0, 16) rstID := make([]typeutil.UniqueID, 0, 16)

View File

@ -1367,7 +1367,7 @@ func TestMetaTable_checkFieldIndexDuplicate(t *testing.T) {
} }
fieldSchema := schemapb.FieldSchema{Name: "test", FieldID: 101} fieldSchema := schemapb.FieldSchema{Name: "test", FieldID: 101}
idxInfo := &pb.IndexInfo{IndexName: "test"} idxInfo := &pb.IndexInfo{IndexName: "test"}
_, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo) _, _, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo)
assert.Error(t, err) assert.Error(t, err)
}) })
@ -1384,7 +1384,7 @@ func TestMetaTable_checkFieldIndexDuplicate(t *testing.T) {
} }
fieldSchema := schemapb.FieldSchema{Name: "test", FieldID: 100} fieldSchema := schemapb.FieldSchema{Name: "test", FieldID: 100}
idxInfo := &pb.IndexInfo{IndexName: "test", IndexParams: []*commonpb.KeyValuePair{{Key: "Key", Value: "not_Value"}}} idxInfo := &pb.IndexInfo{IndexName: "test", IndexParams: []*commonpb.KeyValuePair{{Key: "Key", Value: "not_Value"}}}
_, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo) _, _, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo)
assert.Error(t, err) assert.Error(t, err)
}) })
@ -1401,9 +1401,10 @@ func TestMetaTable_checkFieldIndexDuplicate(t *testing.T) {
} }
fieldSchema := schemapb.FieldSchema{Name: "test", FieldID: 100} fieldSchema := schemapb.FieldSchema{Name: "test", FieldID: 100}
idxInfo := &pb.IndexInfo{IndexName: "test", IndexParams: []*commonpb.KeyValuePair{{Key: "Key", Value: "Value"}}} idxInfo := &pb.IndexInfo{IndexName: "test", IndexParams: []*commonpb.KeyValuePair{{Key: "Key", Value: "Value"}}}
duplicate, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo) duplicate, dupIdxInfo, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo)
assert.NoError(t, err) assert.NoError(t, err)
assert.True(t, duplicate) assert.True(t, duplicate)
assert.Equal(t, idxInfo.IndexName, dupIdxInfo.IndexName)
}) })
t.Run("field not found", func(t *testing.T) { t.Run("field not found", func(t *testing.T) {
@ -1415,9 +1416,10 @@ func TestMetaTable_checkFieldIndexDuplicate(t *testing.T) {
FieldID: 101, FieldID: 101,
} }
idxInfo := &pb.IndexInfo{} idxInfo := &pb.IndexInfo{}
duplicate, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo) duplicate, dupIdxInfo, err := mt.checkFieldIndexDuplicate(collMeta, fieldSchema, idxInfo)
assert.NoError(t, err) assert.NoError(t, err)
assert.False(t, duplicate) assert.False(t, duplicate)
assert.Nil(t, dupIdxInfo)
}) })
} }
@ -1452,10 +1454,12 @@ func TestMetaTable_GetInitBuildIDs(t *testing.T) {
1: { 1: {
IndexName: "GetInitBuildID-Index-1", IndexName: "GetInitBuildID-Index-1",
IndexID: 1, IndexID: 1,
CreateTime: 10,
}, },
2: { 2: {
IndexName: "GetInitBuildID-Index-2", IndexName: "GetInitBuildID-Index-2",
IndexID: 2, IndexID: 2,
CreateTime: 10,
}, },
}, },
} }
@ -1476,6 +1480,7 @@ func TestMetaTable_GetInitBuildIDs(t *testing.T) {
mt.indexID2Meta[3] = pb.IndexInfo{ mt.indexID2Meta[3] = pb.IndexInfo{
IndexName: indexName, IndexName: indexName,
IndexID: 3, IndexID: 3,
CreateTime: 10,
} }
mt.segID2IndexMeta = map[typeutil.UniqueID]map[typeutil.UniqueID]pb.SegmentIndexInfo{ mt.segID2IndexMeta = map[typeutil.UniqueID]map[typeutil.UniqueID]pb.SegmentIndexInfo{
@ -1483,13 +1488,14 @@ func TestMetaTable_GetInitBuildIDs(t *testing.T) {
1: { 1: {
IndexID: 1, IndexID: 1,
EnableIndex: true, EnableIndex: true,
CreateTime: 5,
}, },
}, },
5: { 5: {
3: { 3: {
IndexID: 3, IndexID: 3,
EnableIndex: true, EnableIndex: true,
ByAutoFlush: false, CreateTime: 5,
}, },
}, },
} }
@ -1723,3 +1729,70 @@ func TestMetaTable_MarkIndexDeleted(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
}) })
} }
func TestMetaTable_GetNotIndexedSegments(t *testing.T) {
var (
collName = "MarkIndexDeleted-Coll"
fieldName = "MarkIndexDeleted-Field"
indexName = "MarkIndexDeleted-Index"
collID = UniqueID(1)
fieldID = UniqueID(100)
indexID = UniqueID(1000)
segID = UniqueID(10000)
)
mt := &MetaTable{
txn: &mockTestTxnKV{
multiSave: func(kvs map[string]string) error {
return nil
},
multiRemove: func(keys []string) error {
return nil
},
save: func(key, value string) error {
return nil
},
},
collID2Meta: map[typeutil.UniqueID]pb.CollectionInfo{
collID: {
FieldIndexes: []*pb.FieldIndexInfo{
{
FiledID: fieldID,
IndexID: indexID,
},
},
Schema: &schemapb.CollectionSchema{
Fields: []*schemapb.FieldSchema{
{
FieldID: fieldID,
Name: fieldName,
DataType: schemapb.DataType_FloatVector,
IndexParams: []*commonpb.KeyValuePair{{Key: "index_type", Value: DefaultIndexType}},
},
},
},
},
},
collName2ID: map[string]typeutil.UniqueID{
collName: collID,
},
indexID2Meta: map[typeutil.UniqueID]pb.IndexInfo{
indexID: {
IndexName: indexName,
IndexID: indexID,
IndexParams: []*commonpb.KeyValuePair{{Key: "index_type", Value: DefaultIndexType}},
Deleted: false,
},
},
}
t.Run("GetNotIndexedSegments", func(t *testing.T) {
idxInfo := &pb.IndexInfo{
IndexName: indexName,
IndexID: indexID,
IndexParams: []*commonpb.KeyValuePair{{Key: "index_type", Value: DefaultIndexType}},
CreateTime: 0,
}
_, _, err := mt.GetNotIndexedSegments(collName, fieldName, idxInfo, []UniqueID{segID})
assert.NoError(t, err)
})
}

View File

@ -426,14 +426,19 @@ func (c *Core) createIndexForSegment(ctx context.Context, collID, partID, segID
field, err := GetFieldSchemaByID(&collMeta, fieldIndex.FiledID) field, err := GetFieldSchemaByID(&collMeta, fieldIndex.FiledID)
if err != nil { if err != nil {
log.Debug("GetFieldSchemaByID failed", log.Error("GetFieldSchemaByID failed",
zap.Int64("collectionID", collID), zap.Int64("collectionID", collID),
zap.Int64("fieldID", fieldIndex.FiledID)) zap.Int64("fieldID", fieldIndex.FiledID), zap.Error(err))
return err return err
} }
if c.MetaTable.IsSegmentIndexed(segID, field, indexMeta.IndexParams) { if c.MetaTable.IsSegmentIndexed(segID, field, indexMeta.IndexParams) {
continue continue
} }
createTS, err := c.TSOAllocator(1)
if err != nil {
log.Error("RootCoord alloc timestamp failed", zap.Int64("collectionID", collID), zap.Error(err))
return err
}
segIndexInfo := etcdpb.SegmentIndexInfo{ segIndexInfo := etcdpb.SegmentIndexInfo{
CollectionID: collMeta.ID, CollectionID: collMeta.ID,
@ -442,7 +447,7 @@ func (c *Core) createIndexForSegment(ctx context.Context, collID, partID, segID
FieldID: fieldIndex.FiledID, FieldID: fieldIndex.FiledID,
IndexID: fieldIndex.IndexID, IndexID: fieldIndex.IndexID,
EnableIndex: false, EnableIndex: false,
ByAutoFlush: true, CreateTime: createTS,
} }
buildID, err := c.BuildIndex(ctx, segID, numRows, binlogs, field, &indexMeta, false) buildID, err := c.BuildIndex(ctx, segID, numRows, binlogs, field, &indexMeta, false)
if err != nil { if err != nil {

View File

@ -958,10 +958,15 @@ func (t *CreateIndexReqTask) Execute(ctx context.Context) error {
if err != nil { if err != nil {
return err return err
} }
createTS, err := t.core.TSOAllocator(1)
if err != nil {
return err
}
idxInfo := &etcdpb.IndexInfo{ idxInfo := &etcdpb.IndexInfo{
IndexName: indexName, IndexName: indexName,
IndexID: indexID, IndexID: indexID,
IndexParams: t.Req.ExtraParams, IndexParams: t.Req.ExtraParams,
CreateTime: createTS,
} }
log.Info("create index for collection", log.Info("create index for collection",
zap.String("collection", t.Req.GetCollectionName()), zap.String("collection", t.Req.GetCollectionName()),
@ -1000,7 +1005,7 @@ func (t *CreateIndexReqTask) Execute(ctx context.Context) error {
FieldID: field.FieldID, FieldID: field.FieldID,
IndexID: idxInfo.IndexID, IndexID: idxInfo.IndexID,
EnableIndex: false, EnableIndex: false,
ByAutoFlush: false, CreateTime: createTS,
} }
info.BuildID, err = t.core.BuildIndex(ctx, segID, segID2Binlog[segID].GetNumOfRows(), segID2Binlog[segID].GetFieldBinlogs(), &field, idxInfo, false) info.BuildID, err = t.core.BuildIndex(ctx, segID, segID2Binlog[segID].GetNumOfRows(), segID2Binlog[segID].GetFieldBinlogs(), &field, idxInfo, false)
if err != nil { if err != nil {