Skip to content

Commit 7a5aea1

Browse files
authored
fix: Fix init rootcoord meta timeout (#38248)
issue: #37630 Signed-off-by: bigsheeper <[email protected]>
1 parent 41b19c6 commit 7a5aea1

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

internal/metastore/kv/rootcoord/kv_catalog.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ func (kc *Catalog) appendPartitionAndFieldsInfo(ctx context.Context, collMeta *p
498498
return collection, nil
499499
}
500500

501+
// TODO: This function will be invoked many times if there are many databases, leading to significant overhead.
501502
func (kc *Catalog) batchAppendPartitionAndFieldsInfo(ctx context.Context, collMeta []*pb.CollectionInfo,
502503
ts typeutil.Timestamp,
503504
) ([]*model.Collection, error) {

internal/metastore/kv/rootcoord/suffix_snapshot.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,18 +436,20 @@ func (ss *SuffixSnapshot) generateSaveExecute(ctx context.Context, kvs map[strin
436436
func (ss *SuffixSnapshot) LoadWithPrefix(ctx context.Context, key string, ts typeutil.Timestamp) ([]string, []string, error) {
437437
// ts 0 case shall be treated as fetch latest/current value
438438
if ts == 0 || ts == typeutil.MaxTimestamp {
439-
keys, values, err := ss.MetaKv.LoadWithPrefix(ctx, key)
440-
fks := keys[:0] // make([]string, 0, len(keys))
441-
fvs := values[:0] // make([]string, 0, len(values))
439+
fks := make([]string, 0)
440+
fvs := make([]string, 0)
442441
// hide rootPrefix from return value
443-
for i, k := range keys {
442+
applyFn := func(key []byte, value []byte) error {
444443
// filters tombstone
445-
if ss.isTombstone(values[i]) {
446-
continue
444+
if ss.isTombstone(string(value)) {
445+
return nil
447446
}
448-
fks = append(fks, ss.hideRootPrefix(k))
449-
fvs = append(fvs, values[i])
447+
fks = append(fks, ss.hideRootPrefix(string(key)))
448+
fvs = append(fvs, string(value))
449+
return nil
450450
}
451+
452+
err := ss.MetaKv.WalkWithPrefix(ctx, key, PaginationSize, applyFn)
451453
return fks, fvs, err
452454
}
453455
ss.Lock()

0 commit comments

Comments
 (0)