aerospike / aerospike-client-go

Aerospike Client Go
Apache License 2.0
430 stars 199 forks source link

PARAMETER_ERROR using expressions and batch write #398

Closed wedancedalot closed 1 year ago

wedancedalot commented 1 year ago

Trying to implement conditional update via expressions using versioning for records. BatchOperate doesn't return any error, but the data is not written to aerospike.

UPD: i've noticed that the record has ResultCode: PARAMETER_ERROR inside after the BatchOperate is called.

Is it not possible to do batch writes with expressions? Or maybe there should be some better error? Removing the filter expression makes the record being written. Chaning filter expression to any other doesn't help as well. Here's the example of code i'm using

acc := Account{
    Pubkey:     "test123",
    Data:       []byte{1, 2, 3},
    Version:    1,
}

key, err := aero.NewKey(namespace, set, acc.Pubkey)
if err != nil {
    return err
}

// Create the policy
writePolicy := aero.NewBatchWritePolicy()
writePolicy.FilterExpression = aero.ExpLess(aero.ExpIntBin(binVersion), aero.ExpIntVal(acc.Version))

// Create write operation
record := aero.NewBatchWrite(writePolicy, key,
    aero.PutOp(aero.NewBin(binData, acc.Data)),
    aero.PutOp(aero.NewBin(binVersion, acc.Version)),
)

records := []aero.BatchRecordIfc{record}
err := s.conn.BatchOperate(nil, records)

fmt.Println(err, records)

The result is: nil, [Key test:accounts:test123:d1 02 ed d3 9d bd 5b a9 7e 97 e2 45 8f b6 15 49 54 40 e6 d1 , Record: <nil>, ResultCode: PARAMETER_ERROR, InDoubt: false, Err: <nil>]

The setup i'm using:

Thanks

khaf commented 1 year ago

Your code seems to be ok. To see the actual error, you need to take a look at the server logs.

wedancedalot commented 1 year ago

Hi @khaf

I've set following contexts to debug, but don't see any errors in server logs.

Is there a better way to debug the requests?

khaf commented 1 year ago

I usually use context any debug myself.

wedancedalot commented 1 year ago

I managed to enable the logs and found the error on server side.

WARNING (rw): (write.c:2219) {test} write_master: unknown bin op 0

If the code i'm using is correct it seems like a client issue

wedancedalot commented 1 year ago

@khaf by any chance do you know whether this operation is supported at all? I couldn't find examples of this in both rust and python client libraries. I've noticed that all examples that use batch writes with expressions always use MapPutOp. Is it correct to say that there's no way to use batch PutOp with expressions?

khaf commented 1 year ago

@wedancedalot I expect it to work. Sorry I've been distracted a bit, will take care of this tomorrow.

n00m4d commented 1 year ago

got same issue any updates on this @khaf ?

wedancedalot commented 1 year ago

I've tried some debugging and so far i've found the place where the issue occurs, but having limited knowledge of aerospike wire protocol it's hard to come up with a proper fix

So the issue is happening here https://github.com/aerospike/aerospike-client-go/blob/v6/command.go#L1350-L1365

func (cmd *baseCommand) writeBatchFieldsWithFilter(key *Key, filter *Expression, fieldCount, opCount int) Error {
    if filter != nil {
        fieldCount++
        cmd.writeBatchFields(key, fieldCount, opCount)
        expSize, err := cmd.estimateExpressionSize(filter)
        if err != nil {
            return err
        }
        if err := cmd.writeFilterExpression(filter, expSize); err != nil {
            return err
        }
    } else {
        cmd.writeBatchFields(key, fieldCount, opCount)
    }
    return nil
}

I see there's an increment for fieldCount and writeFilterExpression happening in case filter is not nil. As far as i understand the increment is happening because writeFieldHeader is happening next? But seems like it doesn't work as expected and breaks the final message to the server, so the operation that is received is 0, not 2 due to some shift within the data.

As more operations are added the shift becomes visible even further, as more things are incorrectly received by server:

WARNING (batch): (batch.c:1091) batch request has unknown namespace
WARNING (rw): (write.c:1072) {test} write_master: bin name too long (99) 8e1677bf6e3f8df4e81aede1368b43725f2e1edd
WARNING (rw): (write.c:1072) {test} write_master: bin name too long (99) 00000000052b930101010000001002010004736c
WARNING (batch): (batch.c:1170) Batch keys mismatch. Expected 3 Received 1

So the only version on wire protocol i managed to find is this one, but it has no info whatsoever about fieldHeaders, so def need your help on this one. Thanks

khaf commented 1 year ago

Sorry I've been horizontal this past week. I'll release the fix on Monday.

khaf commented 1 year ago

The fix for this issue was released today in v6.11.0. Feel free to close the ticket if you find the problem resolved.

wedancedalot commented 1 year ago

Thank you, it works!

wedancedalot commented 1 year ago

Seems this has not been fully fixed as there's another problem happening when using NewBatchWrite with FilterExpression. It's either of these panic happen, during inserts.

panic: runtime error: slice bounds out of range [68527:68522]

goroutine 585 [running]:
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeOperationForOperation(0xc0015f1900?, 0xc0019c6a80?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2161 +0x3de
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchOperations(0xc0015f1900?, 0xba67a0?, {0xc00199bd10, 0x5, 0x7780c6?}, 0xc00062c1e0?, 0xc0003a8430?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1033 +0x66
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).setBatchOperateIfc(0xc0015f1900, 0xc0004a0600, {0xc0015a4000, 0x173, 0xc0fae3abdf8447a7?}, 0xf90340?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:707 +0x12e5
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).writeBuffer(0xc0015f1900, {0xba01e0?, 0xc0004a0600?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:55 +0x45
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).executeAt(0xc0015f1900, {0xba6a70, 0xc0015f1900}, 0xc0004a0600, 0xb0?, {0xc00010a898?, 0xc00010a780?, 0xf90340?}, 0xc000411440?, 0x0)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2563 +0xaed
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).execute(0xc00010a840?, {0xba6a70, 0xc0015f1900}, 0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2440 +0x8a
github.com/aerospike/aerospike-client-go/v6.(*baseMultiCommand).execute(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/multi_command.go:410
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).Execute(0xc0003a87b0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:158 +0x2a
github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute.func1()
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:62 +0xc9
created by github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:55 +0x155
panic: runtime error: slice bounds out of range [:106150] with capacity 106104

goroutine 415 [running]:
github.com/aerospike/aerospike-client-go/v6.(*bufferEx).Write(0x7a6482?, {0xc001494000?, 0xc001236f90?, 0x2b?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/bytes_buffer.go:145 +0x90
github.com/aerospike/aerospike-client-go/v6.BytesValue.write(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/value.go:595
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeOperationForOperation(0xc0000ea500, 0xc0010ad260)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2182 +0x32c
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchOperations(0xc0000ea500?, 0xba67a0?, {0xc001658810, 0x5, 0x7780c6?}, 0xc000279180?, 0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1033 +0x66
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).setBatchOperateIfc(0xc0000ea500, 0xc00007cf60, {0xc0010a0000, 0x220, 0xc0fae12a454dcbdc?}, 0xf90340?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:707 +0x12e5
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).writeBuffer(0xc0000ea500, {0xba01e0?, 0xc00007cf60?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:55 +0x45
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).executeAt(0xc0000ea500, {0xba6a70, 0xc0000ea500}, 0xc00007cf60, 0x0?, {0x0?, 0x0?, 0xf90340?}, 0x0?, 0x0)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2563 +0xaed
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).execute(0x0?, {0xba6a70, 0xc0000ea500}, 0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2440 +0x8a
github.com/aerospike/aerospike-client-go/v6.(*baseMultiCommand).execute(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/multi_command.go:410
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).Execute(0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:158 +0x2a
github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute.func1()
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:62 +0xc9
created by github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:55 +0x155
panic: runtime error: slice bounds out of range [:115716] with capacity 115699

goroutine 463 [running]:
github.com/aerospike/aerospike-client-go/v6.(*bufferEx).WriteString(0xc0000ea500?, {0xc0011392f0?, 0x2c?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/bytes_buffer.go:130 +0x90
github.com/aerospike/aerospike-client-go/v6.StringValue.write(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/value.go:633
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeOperationForOperation(0xc0000ea500, 0xc0016cf200)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2182 +0x32c
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchOperations(0xc0000ea500?, 0xba67a0?, {0xc0016bef60, 0x5, 0x7780c6?}, 0xc0002f4820?, 0x10000?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1033 +0x66
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).setBatchOperateIfc(0xc0000ea500, 0xc000424120, {0xc0016a4000, 0x23a, 0xc0fae12bd8f08234?}, 0xf90340?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:707 +0x12e5
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).writeBuffer(0xc0000ea500, {0xba01e0?, 0xc000424120?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:55 +0x45
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).executeAt(0xc0000ea500, {0xba6a70, 0xc0000ea500}, 0xc000424120, 0x0?, {0x0?, 0x0?, 0xf90340?}, 0x0?, 0x0)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2563 +0xaed
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).execute(0x779a54?, {0xba6a70, 0xc0000ea500}, 0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2440 +0x8a
github.com/aerospike/aerospike-client-go/v6.(*baseMultiCommand).execute(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/multi_command.go:410
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).Execute(0x743e66?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:158 +0x2a
github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute.func1()
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:62 +0xc9
created by github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:55 +0x155
panic: runtime error: slice bounds out of range [:108641] with capacity 108633
goroutine 452 [running]:
github.com/aerospike/aerospike-client-go/v6.(*bufferEx).WriteByte(0xc0000023c0?, 0xd8?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/bytes_buffer.go:125 +0x37
github.com/aerospike/aerospike-client-go/v6.packAByte(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/packer.go:577
github.com/aerospike/aerospike-client-go/v6.packArrayBegin({0xba6818?, 0xc0000023c0?}, 0xc0000023c0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/packer.go:93 +0x3b
github.com/aerospike/aerospike-client-go/v6.(*Expression).packExpression(0xc0016bf400, {0xc0016c6010, 0x2, 0xc00042fa68?}, {0xba6818, 0xc0000023c0})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/expression.go:209 +0x86
github.com/aerospike/aerospike-client-go/v6.(*Expression).pack(0xba6818?, {0xba6818?, 0xc0000023c0?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/expression.go:472 +0xbd
github.com/aerospike/aerospike-client-go/v6.(*Expression).packExpression(0xc0016bf600, {0xc0016c6040, 0x2, 0xc00042faf8?}, {0xba6818, 0xc0000023c0})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/expression.go:223 +0x188
github.com/aerospike/aerospike-client-go/v6.(*Expression).pack(0xc0016b0d80?, {0xba6818?, 0xc0000023c0?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/expression.go:472 +0xbd
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeFilterExpression(0xc0000023c0?, 0x0?, 0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2223 +0x85
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchFieldsWithFilter(0x753aac?, 0x9cab20?, 0xc0016bf600, 0xc0000023c0?, 0x4?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1358 +0x5c
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchWrite(0xc0000023c0?, 0xc0016b92c0?, 0x92?, 0xc00042fbb8?, 0x412527?, 0x30?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1058 +0x185
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchOperations(0xc0000023c0?, 0xba67a0?, {0xc0016b09f0, 0x5, 0x7780c6?}, 0xc0005426e0?, 0x3?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1027 +0x3a
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).setBatchOperateIfc(0xc0000023c0, 0xc0000c03c0, {0xc0013f4000, 0x1ff, 0xc0fae13255fc7f4f?}, 0xf90340?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:707 +0x12e5
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).writeBuffer(0xc0000023c0, {0xba01e0?, 0xc0000c03c0?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:55 +0x45
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).executeAt(0xc0000023c0, {0xba6a70, 0xc0000023c0}, 0xc0000c03c0, 0xb0?, {0xc00047e358?, 0xc00047e240?, 0xf90340?}, 0xc0002e2c60?, 0x0)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2563 +0xaed
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).execute(0xc00047e300?, {0xba6a70, 0xc0000023c0}, 0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2440 +0x8a
github.com/aerospike/aerospike-client-go/v6.(*baseMultiCommand).execute(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/multi_command.go:410
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).Execute(0xc00042ffb0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:158 +0x2a
github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute.func1()
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:62 +0xc9
created by github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:55 +0x155
panic: runtime error: slice bounds out of range [95466:95461]

goroutine 439 [running]:
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeFieldString(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2267
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchFields(0xc000142280, 0xc0014f9800, 0xc000142280?, 0xc0014ef680?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1372 +0x290
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchFieldsWithFilter(0x753aac?, 0x9cab20?, 0xc001593f80, 0xc000142280?, 0x4?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1353 +0x33
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchWrite(0xc000142280?, 0xc0015966c0?, 0x92?, 0xc000576bb8?, 0x412527?, 0x30?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1058 +0x185
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).writeBatchOperations(0xc000142280?, 0xba67a0?, {0xc00158e7e0, 0x5, 0x7780c6?}, 0xc000414a00?, 0x0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:1027 +0x3a
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).setBatchOperateIfc(0xc000142280, 0xc00058a720, {0xc0013d2000, 0x1f5, 0xc0fae1390a36ef7f?}, 0xf90340?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:707 +0x12e5
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).writeBuffer(0xc000142280, {0xba01e0?, 0xc00058a720?})
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:55 +0x45
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).executeAt(0xc000142280, {0xba6a70, 0xc000142280}, 0xc00058a720, 0x25?, {0xc000152460?, 0x4?, 0xf90340?}, 0xf99460?, 0x0)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2563 +0xaed
github.com/aerospike/aerospike-client-go/v6.(*baseCommand).execute(0xc000164088?, {0xba6a70, 0xc000142280}, 0xa0?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/command.go:2440 +0x8a
github.com/aerospike/aerospike-client-go/v6.(*baseMultiCommand).execute(...)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/multi_command.go:410
github.com/aerospike/aerospike-client-go/v6.(*batchCommandOperate).Execute(0xf6b900?)
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/batch_command_operate.go:158 +0x2a
github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute.func1()
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:62 +0xc9
created by github.com/aerospike/aerospike-client-go/v6.(*werrGroup).execute
        /go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.11.0/werrgroup.go:55 +0x155

Inserting the same batch of records with omitting FilterExpression works without any problems at all

khaf commented 1 year ago

Can you provide a little gist that triggers the issue?

wedancedalot commented 1 year ago

yeah, im trying to run exactly this code. But what is weird is that this function doesn't always fail, but try running it a couple of times and it eventually does. But when FilterExpression is removed it never fails

func Test(client *aero.Client) error {
    batchRecords := []aero.BatchRecordIfc{}

    for _, acc := range []struct {
        Key  string 
        Slot int64
        Data []byte
    }{
        {
            Key:  "WzoM8sW2FkDyJuwsftk9wzHCtE32t2dZqzcY8b4Bp6V",
            Slot: 123456,
            Data: make([]byte, 156810),
        },
        {
            Key:  "2fwBjaKmvm8BJU3WNuEgvc9zYmyHb5HAznZuZ4kENAju",
            Slot: 123456,
            Data: make([]byte, 156810),
        },
    } {
        // Create key
        key, err := aero.NewKey("ns", "set", acc.Key)
        if err != nil {
            return err
        }

        // Create the policy
        writePolicy := aero.NewBatchWritePolicy()
        writePolicy.Expiration = 0
        writePolicy.FilterExpression = aero.ExpAnd(
            aero.ExpBinExists("slot"),
            aero.ExpLess(aero.ExpIntBin("slot"), aero.ExpIntVal(acc.Slot)),
        )

        // Create write operation
        record := aero.NewBatchWrite(writePolicy, key,
            aero.PutOp(aero.NewBin("data", acc.Data)),
        )

        // Add to batch
        batchRecords = append(batchRecords, record)
    }

    err := client.BatchOperate(nil, batchRecords)
    if err != nil {
        return errors.Wrap(err, "batch operate")
    }

    return nil
}
khaf commented 1 year ago

I'll find the issue, no worries.

wedancedalot commented 1 year ago

hi @khaf is there any update on this issue? i tried to debug this myself but got stuck. could you hint on where to look. this functionality is highly required for my setup but i can't seem to get it running. so any help is much appreciated

khaf commented 1 year ago

I am actively working on it. I had to develop a complex testing scheme to be able to reliably reproduce the issue. But now that I have, I'm trying to find out what's causing it. It only happens under certain complex conditions (which you have hit!). I'll try to push the fix out tomorrow, or latest Monday. Sorry for the inconvenience and the slow pace of progress, but I promise this time to test it well enough to make sure the thing works as expected.

wedancedalot commented 1 year ago

Gotcha, thanks a lot for helping out @khaf !

khaf commented 1 year ago

@wedancedalot Released in v6.12.0.

wedancedalot commented 1 year ago

Just tested, seems to be working without any issues. Big thanks for your help @khaf I'm closing this issue

khaf commented 1 year ago

Sorry for the inconvenience. Let me know if you hit any other snag, will take care of it ASAP.