#466

BatchGetComplex doesn't work with ReadAllBins set to true

Openyizhaopened 1y ago

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.

Activity

3
khaf1y ago

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

yizha1y ago

I am upgrading the aerospike client in an existing app.

matthewd987mo ago

I'm experiencing the same issue after upgrading from v6 to v7 (currently on v7.10.2). The proposed fix (using aerospike.NewBatchReadOps(nil, key, aerospike.GetOp())) worked for me, but the latency of calls increased by 0.2ms on our shared clusters. I'm not sure whether the slowdown is due to aerospike.NewBatchReadOps() itself or to BatchGetComplex()