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

Can't get space length via tarantool.crud #394

Closed
Vlad97vsv opened this issue Apr 16, 2024 · 4 comments
Closed

Can't get space length via tarantool.crud #394

Vlad97vsv opened this issue Apr 16, 2024 · 4 comments
Labels
needs feedback Something is unclear with the issue

Comments

@Vlad97vsv
Copy link

Vlad97vsv commented Apr 16, 2024

Can't get space length via crud.len

I get an error: array len doesn't match: 1

db - is connected ConnectionPool

func getLen() uint64 {
	space := "test_space"
	req := tarantoolcrud.MakeLenRequest(space)
	data := tarantoolcrud.LenResult{}
	if err := db.Do(req, tarantoolpool.ANY).GetTyped(&data); err != nil {
		panic(err)
	}
	fmt.Println(data.Value)
	return data.Value
}

>>> panic: array len doesn't match: 1

When I use Count query everything is ok.

func getCount() uint64 {
	space := "test_space"
	req := tarantoolcrud.MakeCountRequest(space)
	data := tarantoolcrud.CountResult{}
	if err := db.Do(req, tarantoolpool.ANY).GetTyped(&data); err != nil {
		panic(err)
	}
	fmt.Println(data.Value)
	return data.Value
}
`>>> 10000`

If you look at what arrives, you can see that only 1 entry in the array arrives for crud.len. And for count there are 2 entries:

func (r *MetaTntRepositoryVShard) getCount2() {
	space := "test_space"
	req := crud.MakeCountRequest(space)
	if data, err := db.Do(req, tarantoolpool.ANY).Get(); err != nil {
		panic(err)
	} else {
		fmt.Printf("%+v\n", data)
	}
}
image

The error occurs precisely during serialization. Therefore the code below works

func (r *MetaTntRepositoryVShard) getLen2() {
	space := "test_space"
	req := crud.MakeLenRequest(space)
	if data, err := db.Do(req, tarantoolpool.ANY).Get(); err != nil {
		panic(err)
	} else {
		fmt.Printf("%+v\n", data)
	}
}
image

Crud is installed, everything works correctly via tarantoolctl crud.len works.


The error seems clear, but I can’t understand why tarantool returns 1 field when asking for length.


golang version: 1.21.1
lib: go-tarantool/v2 2.0.0
OS: MacOs
tarantool version: 2.11

@DifferentialOrange
Copy link
Member

DifferentialOrange commented Apr 16, 2024

The error seems clear, but I can’t understand why tarantool returns 1 field when asking for length.

To be honest, it's more weird that every (or almost every) other method returns explicit result, nil in case of success.

@oleg-jukovec oleg-jukovec added 1sp bug Something isn't working teamE labels Apr 16, 2024
@oleg-jukovec
Copy link
Collaborator

oleg-jukovec commented Apr 16, 2024

Thank you for the issue, are you sure that go-tarantool version is exactly v2.0.0? It should be fixed with:
c3ba5b5

Please, write a crud version because I can’t reproduce the problem. It works fine for me:

// ExampleLenRequest demonstrates how to execute a LenRequest.
func ExampleLenRequest() {
	conn := exampleConnect()
	req := crud.MakeLenRequest(exampleSpace)

	ret := crud.LenResult{}
	if err := conn.Do(req).GetTyped(&ret); err != nil {
		fmt.Printf("Failed to execute request: %s", err)
		return
	}

	fmt.Println(ret.Value)
	// Output:
	// 4
}

Please, make sure that go-tarantool version is release and v2.0.0 at least (or you could use v2.1.0 to make sure).

@oleg-jukovec oleg-jukovec added needs feedback Something is unclear with the issue and removed bug Something isn't working 1sp teamE labels Apr 16, 2024
@Vlad97vsv
Copy link
Author

I use github.com/tarantool/go-tarantool/v2 v2.0.0-20230823074441-d8df65dcd0f2.


Thank you. I'll try to update to 2.1.0 and will be back with feedback

@Vlad97vsv
Copy link
Author

With the update to version 2.1.0 the problem disappeared.

Thank you very much for the quick response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs feedback Something is unclear with the issue
Projects
None yet
Development

No branches or pull requests

3 participants