Skip to content

Commit

Permalink
Use the GetLoadingProgress api instead of the InMemoryPercentages in …
Browse files Browse the repository at this point in the history
…the ShowPartition api response

Fix load collection hang issue

Signed-off-by: Wen Sun <[email protected]>
  • Loading branch information
xwjdsh committed Mar 17, 2023
1 parent 7fb93bf commit d6040af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 39 deletions.
8 changes: 4 additions & 4 deletions client/client_grpc_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,15 @@ func (c *GrpcClient) LoadCollection(ctx context.Context, collName string, async
default:
}

coll, err := c.ShowCollection(ctx, collName)
progress, err := c.GetLoadingProgress(ctx, collName, nil)
if err != nil {
return err
}
if coll.Loaded {
break
if progress == 100 {
return nil
}

time.Sleep(200 * time.Millisecond) // TODO change to configuration
time.Sleep(500 * time.Millisecond)
}
}
return nil
Expand Down
41 changes: 6 additions & 35 deletions client/client_grpc_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,6 @@ func (c *GrpcClient) LoadPartitions(ctx context.Context, collName string, partit
return err
}
}
partitions, err := c.ShowPartitions(ctx, collName)
if err != nil {
return err
}
m := make(map[string]int64)
for _, partition := range partitions {
m[partition.Name] = partition.ID
}
// load partitions ids
ids := make(map[int64]struct{})
for _, partitionName := range partitionNames {
id, has := m[partitionName]
if !has {
return fmt.Errorf("Collection %s does not has partitions %s", collName, partitionName)
}
ids[id] = struct{}{}
}

req := &server.LoadPartitionsRequest{
DbName: "", // reserved
Expand All @@ -187,28 +170,16 @@ func (c *GrpcClient) LoadPartitions(ctx context.Context, collName string, partit
return errors.New("context deadline exceeded")
default:
}
partitions, err := c.ShowPartitions(ctx, collName)
percentage, err := c.GetLoadingProgress(ctx, collName, partitionNames)
if err != nil {
return err
}
foundLoading := false
loaded := 0
for _, partition := range partitions {
if _, has := ids[partition.ID]; !has {
continue
}
if !partition.Loaded {
//Not loaded
foundLoading = true
break
}
loaded++
}
if foundLoading || loaded < len(partitionNames) {
time.Sleep(time.Millisecond * 100)
continue

if percentage == 100 {
return nil
}
break

time.Sleep(500 * time.Millisecond)
}
}

Expand Down

0 comments on commit d6040af

Please sign in to comment.