Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed Dec 13, 2022
1 parent 27a1d42 commit 4cf9e14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/agent/core/ngt/service/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) {
wf := atomic.AddUint64(&n.wfci, 1)
if wf > 1 {
atomic.AddUint64(&n.wfci, ^uint64(0))
log.Warnf("concurrent create index waiting detected this request will be ignored, concurrent: %d", wf)
log.Debugf("concurrent create index waiting detected this request will be ignored, concurrent: %d", wf)
return nil
}
err = func() error {
Expand Down
15 changes: 9 additions & 6 deletions pkg/agent/core/ngt/service/ngt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package service

import (
"fmt"
"context"
"reflect"
"sync"
Expand Down Expand Up @@ -11493,13 +11494,14 @@ func Test_ngt_InsertUpsert(t *testing.T) {

if count >= test.args.bulkSize {
wg.Add(1)
go func() {
eg.Go(func()error{
defer wg.Done()
err = n.CreateAndSaveIndex(ctx, test.args.poolSize)
if err != nil {
tt.Errorf("error creating index: %v", err)
}
}()
return nil
})
count = 0
}
}
Expand All @@ -11525,13 +11527,14 @@ func Test_ngt_InsertUpsert(t *testing.T) {

if count >= test.args.bulkSize {
wgu.Add(1)
go func() {
eg.Go(func()error{
defer wgu.Done()
err = n.CreateAndSaveIndex(ctx, test.args.poolSize)
if err != nil {
tt.Errorf("error creating index: %v", err)
}
}()
return nil
})
count = 0
}
}
Expand All @@ -11548,9 +11551,9 @@ func Test_ngt_InsertUpsert(t *testing.T) {
func createRandomData(num int) []index {
result := make([]index, 0)
f32s, _ := vector.GenF32Vec(vector.Gaussian, num, 128)
for _, vec := range f32s {
for idx, vec := range f32s {
result = append(result, index{
uuid: uuid.New().String(),
uuid: fmt.Sprintf("%s-%s:%d:%d,%d",uuid.New().String(), uuid.New().String(), idx, idx/100,idx%100),
vec: vec,
})
}
Expand Down

0 comments on commit 4cf9e14

Please sign in to comment.