Skip to content

Commit

Permalink
Fix load partition getting stuck
Browse files Browse the repository at this point in the history
Signed-off-by: bigsheeper <[email protected]>
  • Loading branch information
bigsheeper committed Mar 17, 2023
1 parent 7fb93bf commit d366402
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
13 changes: 5 additions & 8 deletions client/client_grpc_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import (
"time"

"github.com/cockroachdb/errors"

"github.com/golang/protobuf/proto"
"github.com/milvus-io/milvus-sdk-go/v2/entity"
"google.golang.org/grpc"

common "github.com/milvus-io/milvus-proto/go-api/commonpb"
server "github.com/milvus-io/milvus-proto/go-api/milvuspb"
"github.com/milvus-io/milvus-sdk-go/v2/entity"
)

// GrpcClient, uses default grpc Service definition to connect with Milvus2.0
Expand Down Expand Up @@ -372,16 +371,14 @@ func (c *GrpcClient) LoadCollection(ctx context.Context, collName string, async
return errors.New("context deadline exceeded")
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(time.Millisecond * 500)
}
}
return nil
Expand Down
39 changes: 4 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,14 @@ func (c *GrpcClient) LoadPartitions(ctx context.Context, collName string, partit
return errors.New("context deadline exceeded")
default:
}
partitions, err := c.ShowPartitions(ctx, collName)
progress, 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 progress == 100 {
return nil
}
break
time.Sleep(time.Millisecond * 500)
}
}

Expand Down

0 comments on commit d366402

Please sign in to comment.