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

BatchGetComplex doesn't work with ReadAllBins set to true #466

Open
yizha opened this issue Feb 21, 2025 · 1 comment
Open

BatchGetComplex doesn't work with ReadAllBins set to true #466

yizha opened this issue Feb 21, 2025 · 1 comment

Comments

@yizha
Copy link

yizha commented Feb 21, 2025

Aerospike server version: 7.2.0.6_1
Aerospike client (golang) version: v7.8.0

Below code fails with ResultCode: PARAMETER_ERROR, Iteration: 0, InDoubt: false, Node: BB9060012AC4202 [::1]:3000: No operations were passed. when it calls BatchGetComplex(...).

package main

import (
	"fmt"
	"net"
	"strconv"

	"github.com/aerospike/aerospike-client-go/v7"
)

func p(err any) {
	if err != nil {
		panic(err)
	}
}

func createAerospikeClient(addr string) *aerospike.Client {
	host, portStr, err := net.SplitHostPort(addr)
	p(err)
	port, err := strconv.Atoi(portStr)
	p(err)
	client, err := aerospike.NewClient(host, port)
	p(err)
	return client
}

func main() {
	client := createAerospikeClient("localhost:3000")

	key, err := aerospike.NewKey("namespace", "set", "key")
	p(err)

	rec, err := client.Get(nil, key)
	p(err)
	fmt.Printf("Get() record: %+v\n", rec)

	read := aerospike.NewBatchRead(nil, key, nil)
	read.ReadAllBins = true
	// read := aerospike.NewBatchReadOps(nil, key, aerospike.GetOp())

	reads := []*aerospike.BatchRead{read}

	policy := aerospike.NewBatchPolicy()
	p(client.BatchGetComplex(policy, reads))
	fmt.Printf("BatchGetComplex() record: %+v\n", read.Record)
}

But if we replace

	read := aerospike.NewBatchRead(nil, key, nil)
	read.ReadAllBins = true

with

	read := aerospike.NewBatchReadOps(nil, key, aerospike.GetOp())

then BatchGetComplex(...) works.

@khaf
Copy link
Collaborator

khaf commented Feb 26, 2025

I cannot reproduce this issue in v8 of the client. Are you trying to use this in an existing app or a new app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants