Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix load partition getting stuck #424

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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