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

add broken index backup #2034

Merged
merged 36 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c541b3a
update devcontainer to run ngt locally
ykadowak May 22, 2023
a46cebd
add .vscode to .gitignore
ykadowak May 23, 2023
0afd8c7
log on force starting with in-mem mode when n.path is empty
ykadowak May 23, 2023
aa78242
init broken inded backup path
ykadowak May 23, 2023
9f8cf67
move remove logic to service
ykadowak May 24, 2023
e6e014b
style: Format code with gofumpt and prettier
deepsource-autofix[bot] May 24, 2023
672748d
add test to check broken folder created
ykadowak May 26, 2023
ac201ba
check if the index path exists
ykadowak May 26, 2023
25bd52b
implementing migration process
ykadowak May 26, 2023
8175def
remove check apis/proto/v1
ykadowak May 29, 2023
9ab8884
revert log
ykadowak May 29, 2023
7869c51
keep implementing migration
ykadowak May 29, 2023
1039a99
style: Format code with gofumpt and prettier
deepsource-autofix[bot] May 29, 2023
58fc884
use filepath
ykadowak May 30, 2023
7dc92a9
refactor test
ykadowak May 30, 2023
5bd6b8f
implement the backup logic and its test
ykadowak May 30, 2023
c3af335
add index testdata
ykadowak May 31, 2023
02ef60b
style: Format code with prettier and gofumpt
deepsource-autofix[bot] May 31, 2023
255c7be
implement needsBackup
ykadowak May 31, 2023
eec3d6e
refactor test
ykadowak May 31, 2023
1cbd4e7
add broken_index_history_limit to the charts
ykadowak Jun 2, 2023
098b001
add log
ykadowak Jun 2, 2023
9c4f529
add comment
ykadowak Jun 2, 2023
ec9762d
Merge branch 'main' into feature/agent/broken-index-backup
ykadowak Jun 2, 2023
1d8c58b
fix
ykadowak Jun 2, 2023
4283606
fix for reviewdog
ykadowak Jun 2, 2023
d683c00
fix stylecheck
ykadowak Jun 2, 2023
e2bd4c7
Update pkg/agent/core/ngt/service/ngt.go
ykadowak Jun 2, 2023
8354446
refactor file path join
ykadowak Jun 2, 2023
d59b436
refactor
ykadowak Jun 7, 2023
c55b051
use slices.Sort
ykadowak Jun 7, 2023
cba602e
error handling for os.RemoveAll
ykadowak Jun 7, 2023
669bb56
stop hard coding metadata.json
ykadowak Jun 7, 2023
e40e9cb
pass context from higher
ykadowak Jun 7, 2023
42d1e47
Merge branch 'main' into feature/agent/broken-index-backup
ykadowak Jun 7, 2023
f866a3f
refactor
ykadowak Jun 7, 2023
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
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"moby": "true"
}
},
"postCreateCommand": "go version"
"postCreateCommand": "go version",
"postAttachCommand": "sudo ln -s $(pwd)/cmd/agent/core/ngt/sample.yaml /etc/server/config.yaml"
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ hack/go.mod.default3
# for nvim
.nvimlog

# for vscode
.vscode/

telepresence.log
3 changes: 1 addition & 2 deletions Makefile.d/proto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ proto/deps: \
$(GOPATH)/src/github.com/planetscale/vtprotobuf \
$(GOPATH)/src/github.com/protocolbuffers/protobuf \
$(GOPATH)/src/google.golang.org/genproto \
$(GOPATH)/src/google.golang.org/protobuf \
$(ROOTDIR)/apis/proto/v1
$(GOPATH)/src/google.golang.org/protobuf

$(GOPATH)/src/github.com/protocolbuffers/protobuf:
git clone \
Expand Down
3 changes: 3 additions & 0 deletions charts/vald/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,9 @@ agent:
# @schema {"name": "agent.ngt.kvsdb.concurrency", "type": "integer"}
# agent.ngt.kvsdb.concurrency -- kvsdb processing concurrency
concurrency: 6
# @schema {"name": "agent.ngt.broken_index_history_limit", "type": "integer"}
# agent.ngt.broken_index_history_limit -- maximum number of broken index generations to backup
broken_index_history_limit: 0
# @schema {"name": "agent.sidecar", "type": "object"}
sidecar:
# @schema {"name": "agent.sidecar.enabled", "type": "boolean"}
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/core/ngt/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ ngt:
object_type: float
search_edge_size: 10
enable_copy_on_write: false
broken_index_history_limit: 0
5 changes: 5 additions & 0 deletions dockers/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ RUN make ngt/install \
&& make kubectl/install \
&& make k3d/install

# change GOPATH owner to vscode to run commands as user vscode without root permission
RUN chown -R vscode:vscode "${GOPATH}" \
# mkdir for agent configuration install
&& mkdir -p /etc/server

# k9s installs the binary to the current user which is root for devcontainer
# so change the current user to vscode to user afterwards
USER vscode
Expand Down
3 changes: 3 additions & 0 deletions internal/config/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type NGT struct {

// KVSDB represent the ngt bidirectional kv store configuration
KVSDB *KVSDB `json:"kvsdb,omitempty" yaml:"kvsdb"`

// BrokenIndexHistoryLimit represents the maximum number of broken index generations that will be backed up
BrokenIndexHistoryLimit int `yaml:"broken_index_history_limit" json:"broken_index_history_limit,omitempty"`
}

// KVSDB represent the ngt vector bidirectional kv store configuration
Expand Down
13 changes: 0 additions & 13 deletions internal/core/algorithm/ngt/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ package ngt
import "C"

import (
"os"
"reflect"
"sync"
"unsafe"
Expand Down Expand Up @@ -307,18 +306,6 @@ func (n *ngt) loadOptions(opts ...Option) (err error) {
}

func (n *ngt) create() (err error) {
files, err := file.ListInDir(n.idxPath)
if err == nil && len(files) != 0 {
log.Warnf("index path exists, will remove the directories: %v", files)
for _, f := range files {
err = os.RemoveAll(f)
if err != nil {
return err
}
}
} else if err != nil {
log.Debug(err)
}
path := C.CString(n.idxPath)
defer C.free(unsafe.Pointer(path))

Expand Down
5 changes: 5 additions & 0 deletions internal/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ var (
return Wrapf(err, "failed to output %s logs", str)
}

// ErrIndexPathNotExists represents a function to generate an error that the index path is not exists.
ErrIndexPathNotExists = func(path string) error {
return Errorf("index path %s not exists", path)
}

// New represents a function to generate the new error with a message.
// When the message is nil, it will return nil instead of an error.
New = func(msg string) error {
Expand Down
1 change: 1 addition & 0 deletions internal/test/data/agent/ngt/validIndex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory holds an outcome of inserting `datafashion-mnist-784-euclidean` to Vald agent by using `example/client/agent/main.go` with `insertCount = 100`.
Binary file added internal/test/data/agent/ngt/validIndex/grp
Binary file not shown.
1 change: 1 addition & 0 deletions internal/test/data/agent/ngt/validIndex/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "is_invalid": false, "ngt": { "index_count": 100 } }
Binary file not shown.
Binary file not shown.
Binary file added internal/test/data/agent/ngt/validIndex/obj
Binary file not shown.
26 changes: 26 additions & 0 deletions internal/test/data/agent/ngt/validIndex/prf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
AccuracyTable
BatchSizeForCreation 200
BuildTimeLimit 0
DatabaseType Memory
Dimension 784
DistanceType L2
DynamicEdgeSizeBase 30
DynamicEdgeSizeRate 20
EdgeSizeForCreation 20
EdgeSizeForSearch 10
EdgeSizeLimitForCreation 5
EpsilonForCreation 0.1
GraphType ANNG
IncomingEdge 80
IncrimentalEdgeSizeLimitForTruncation 0
IndexType GraphAndTree
ObjectAlignment False
ObjectType Float-4
OutgoingEdge 10
PathAdjustmentInterval 0
PrefetchOffset 1
PrefetchSize 3136
SeedSize 10
SeedType None
ThreadPoolSize 32
TruncationThreadPoolSize 8
Binary file added internal/test/data/agent/ngt/validIndex/tre
Binary file not shown.
4 changes: 4 additions & 0 deletions internal/test/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
"github.com/vdaas/vald/internal/strings"
)

const (
ValidIndex = "agent/ngt/validIndex"
)

// GetTestdataPath returns the test data file path under `internal/test/data`.
func GetTestdataPath(filename string) string {
return file.Join(baseDir(), "/internal/test/data/", filename)
Expand Down
Loading