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

Wrong index arity after reopen an existing DB(multiple index) #433

Closed
abramlab opened this issue Sep 17, 2021 · 1 comment · Fixed by #434
Closed

Wrong index arity after reopen an existing DB(multiple index) #433

abramlab opened this issue Sep 17, 2021 · 1 comment · Fixed by #434
Labels
bug Something isn't working

Comments

@abramlab
Copy link
Contributor

What version of Genji are you using?

$ genji version

Genji v0.13.0
Genji CLI v0.13.0

Does this issue reproduce with the latest release?

Yes

What did you do?

genji test_index.db

CREATE TABLE cars (name TEXT NOT NULL, color TEXT NOT NULL, price VARCHAR(128));

CREATE UNIQUE INDEX idx_cars_name_color ON cars(name, color);

INSERT INTO cars (name, color, price) VALUES ("Tesla", "Red", "100000");
{
  "name": "Tesla",
  "color": "Red",
  "price": "100000"
}

UPDATE cars SET price = '500000' WHERE (name = 'Tesla' AND color = 'Red');

exit

genji test_index.db

UPDATE cars SET price = '777777' WHERE (name = 'Tesla' AND color = 'Red');
wrong index arity <- here I get an ERROR!

The same behavior is observed in the runnable program, not only in CLI.
The problem only occurs when you run it again on an already created database.

What did you expect to see?

Correct record update, no mistake.

What did you see instead?

Error: wrong index arity

What Go version and environment are you using?

$ go version

go version go1.17 linux/amd64
go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/misha/.cache/go-build"
GOENV="/home/misha/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/misha/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/misha/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2235764675=/tmp/go-build -gno-record-gcc-switches"

Code research

In my research on the code, I came to the conclusion that this problem may be because when indexes loading from existing database https://github.com/genjidb/genji/blob/b9b312418718f6eb24f7fea5ce480aa133e526e3/internal/catalog/catalog.go#L73
their types are not filled
https://github.com/genjidb/genji/blob/b9b312418718f6eb24f7fea5ce480aa133e526e3/internal/database/info.go#L90

In the case when the database is created for the first time, the types are successfully added when creating the index
https://github.com/genjidb/genji/blob/b9b312418718f6eb24f7fea5ce480aa133e526e3/internal/catalog/catalog.go#L300

@abramlab abramlab added the bug Something isn't working label Sep 17, 2021
@abramlab abramlab changed the title Wrong index arity after reopen an existing DB Wrong index arity after reopen an existing DB(multiple index) Sep 20, 2021
@asdine
Copy link
Collaborator

asdine commented Sep 24, 2021

Thanks for reporting @abramlab ! @KudinovKV fixed this issue (#434), feel free to reopen if you still experience the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants