Skip to content

Commit

Permalink
invest removeInvalidIndex bug
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed Feb 20, 2024
1 parent f080436 commit fbebc42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/agent/core/ngt/service/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,12 +1274,15 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) {
}

func (n *ngt) removeInvalidIndex(ctx context.Context) {
log.Debug("[CHECK20240220]\tremoveInvalidIndex started")
if n.kvs.Len() == 0 {
log.Debug("[CHECK20240220]\tremoveInvalidIndex kvs Len is empty")
return
}
var dcnt uint32
n.kvs.Range(ctx, func(uuid string, oid uint32, _ int64) bool {
vec, err := n.core.GetVector(uint(oid))
log.Debugf("[CHECK20240220]\tuuid: %s,\toid: %d,\tvec: %#v,\terr: %v", uuid, oid, vec, err)

Check warning on line 1285 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1285

Added line #L1285 was not covered by tests
if err != nil || vec == nil || len(vec) != n.dim {
log.Debugf("invalid index detected err: %v\tuuid: %s\toid: %d will remove", err, uuid, oid)
n.kvs.Delete(uuid)
Expand All @@ -1295,6 +1298,7 @@ func (n *ngt) removeInvalidIndex(ctx context.Context) {
return true
})
if atomic.LoadUint32(&dcnt) <= 0 {
log.Debug("[CHECK20240220]\tremoveInvalidIndex deleted count is empty")

Check warning on line 1301 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1301

Added line #L1301 was not covered by tests
return
}
var poolSize uint32
Expand All @@ -1303,6 +1307,8 @@ func (n *ngt) removeInvalidIndex(ctx context.Context) {
} else {
poolSize = atomic.LoadUint32(&dcnt)
}
log.Debug("[CHECK20240220]\tremoveInvalidIndex before cimu.Lock")
defer log.Debug("[CHECK20240220]\tremoveInvalidIndex after cimu.Lock")

Check warning on line 1311 in pkg/agent/core/ngt/service/ngt.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/core/ngt/service/ngt.go#L1310-L1311

Added lines #L1310 - L1311 were not covered by tests
n.cimu.Lock()
defer n.cimu.Unlock()
n.indexing.Store(true)
Expand Down
6 changes: 6 additions & 0 deletions pkg/agent/internal/kvs/kvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"sync/atomic"

"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/safety"
"github.com/vdaas/vald/internal/sync"
"github.com/vdaas/vald/internal/sync/errgroup"
Expand Down Expand Up @@ -159,12 +160,17 @@ func (b *bidi) Range(ctx context.Context, f func(string, uint32, int64) bool) {
b.uo[idx].Range(func(uuid string, val ValueStructUo) bool {
select {
case <-ctx.Done():
err = ctx.Err()

Check warning on line 163 in pkg/agent/internal/kvs/kvs.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/internal/kvs/kvs.go#L163

Added line #L163 was not covered by tests
return false
default:
return f(uuid, val.value, val.timestamp)
}
})
wg.Done()
if err != nil &&
(errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)) {
return err
}

Check warning on line 173 in pkg/agent/internal/kvs/kvs.go

View check run for this annotation

Codecov / codecov/patch

pkg/agent/internal/kvs/kvs.go#L172-L173

Added lines #L172 - L173 were not covered by tests
return nil
}))
}
Expand Down

0 comments on commit fbebc42

Please sign in to comment.