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 the issue of loading partition hanging #422

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
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
10 changes: 5 additions & 5 deletions client/client_grpc_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,25 +389,25 @@ func TestGrpcClientLoadCollection(t *testing.T) {
start := time.Now()

mockServer.SetInjection(MShowCollections, func(_ context.Context, raw proto.Message) (proto.Message, error) {
req, ok := raw.(*server.ShowCollectionsRequest)
r := &server.ShowCollectionsResponse{}
req, ok := raw.(*server.GetLoadingProgressRequest)
r := &server.GetLoadingProgressResponse{}
if !ok || req == nil {
s, err := BadRequestStatus()
r.Status = s
return r, err
}
s, err := SuccessStatus()
r.Status = s
r.CollectionIds = []int64{1}
var perc int64
if time.Since(start) > time.Duration(loadTime)*time.Millisecond {
t.Log("passed")
perc = 100
passed = true
}
r.InMemoryPercentages = []int64{perc}
r.Progress = perc
return r, err
})

assert.Nil(t, c.LoadCollection(ctx, testCollectionName, false))
assert.True(t, passed)

Expand All @@ -418,7 +418,7 @@ func TestGrpcClientLoadCollection(t *testing.T) {
assert.NotNil(t, c.LoadCollection(quickCtx, testCollectionName, false))

// remove injection
mockServer.DelInjection(MShowCollections)
mockServer.DelInjection(MGetLoadingProgress)
})
t.Run("Load default replica", func(t *testing.T) {
mockServer.SetInjection(MLoadCollection, func(ctx context.Context, raw proto.Message) (proto.Message, error) {
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