Parameter Error when writing a record using RecordExistsAction.REPLACE

Aerospike server version: 6.3 Aerospike Java client version: 6.1.1

When I create or update a record with 3 bins (two string values and one a Map), with WritePolicy having RecordExistsAction.REPLACE:

WritePolicy writePolicy = new WritePolicy()
writePolicy.recordExistsAction = RecordExistsAction.UPDATE;
);
Key key = new Key("namespace", null, "1");
aerospikeClient.put(writePolicy, key, 
                              new Bin("id", "1"), new Bin("type", "app"), //string values
                             new Bin("list_id", ImmutableMap.of("123", 2345L)) //map object
);

The client fails throwing an exception:

com.aerospike.client.AerospikeException: Error 4,1,0,30000,1000,0,BBBB 10.X.X.X 3000: Parameter error
	at com.aerospike.client.command.WriteCommand.parseResult(WriteCommand.java:82)
	at com.aerospike.client.command.SyncCommand.executeCommand(SyncCommand.java:103)
	at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:63)
	at com.aerospike.client.AerospikeClient.put(AerospikeClient.java:481)

However when I try the same update using RecordExistsAction.UPDATE in the Write policy the write/update succeeds.

Why does this happen?

I saw this old topic - Aerospike Exception Error Code 4 Parameter Error when doing a put through java client , but it was for a bin with null values. in this case the 3 bins had valid values. So I am not sure.

Share your code …?

1 Like

@pgupta I added the code. I do not see this error when testing the write on a Docker image “aerospike:ee-6.3.0.2_1”. I see the error only when I send this write to a cluster running 6.3.x.

Hi Shan. Your code looks like it should work (apart from a couple of minor compile errors). I’ve been able to run it in my environment with no issues. You’re using the null set which is ok, but the vast majority of applications would have a set name in there. (A set is like a table in relational concepts, so it allows for different business objects like Customers and Addresses to be grouped together).

When you get a Parameter Error, there is quite often more information in the server log about what is happening. So if you’re able to reproduce the error at will, can you please tail the log on the server where the record resides when the error occurs and see if there’s more information in there? That would help us guide you to solving the problem.

If you have multiple nodes in the cluster, it needs to be the node which holds the record. This is easy to tell via AQL:

aql> explain select * from test where pk = "1"
+--------------------------------------------+----------+-------------------+-----------+-----------+----------------------+-----+--------+---------+---------+
| DIGEST                                     | KEY_TYPE | MASTER NODE       | NAMESPACE | PARTITION | POLICY_KEY           | SET | STATUS | TIMEOUT | UDF     |
+--------------------------------------------+----------+-------------------+-----------+-----------+----------------------+-----+--------+---------+---------+
| "B5C4A6BECFB3398605BEDD937F9AE941D0CEE1DE" | "STRING" | "BB963931E03E652" | "test"    | 1205      | "AS_POLICY_KEY_SEND" | ""  | ""     | 1000    | "FALSE" |
+--------------------------------------------+----------+-------------------+-----------+-----------+----------------------+-----+--------+---------+---------+
1 row in set (0.003 secs)

So in this case the node would be BB963931E03E652. (Your node will obviously be different, but this shows you how to get the particular node) You can then use asadm’s info command to map this back to the node on which to tail the log.

Please post what the error is in the log so we can help more.

@TimF Thanks for the troubleshooting ideas.

I tailed the log and see the following error/warning when creating the record:

Jan 29 2025 01:43:42 GMT: WARNING (rw): (write.c:1029) {app_lists} write_master: can't replace record 7f6c8627e3c03e5105b51f622dc093d115e2e4c0 if conflict resolving

I also see that this error happens on the cluster that has XDR enabled.

Here is the XDR config for the app:

xdr {
    src-id 1
    dc .... {
        node-address-port aerospike-server-.....
namespace app_lists {
            bin-policy only-changed
            ship-bin-luts true
            enable-compression true
            compression-level 4
            max-throughput 100000
        }

@shan.p – That makes sense now. I’m assuming in your namespace you have conflict-resolve-writes set to true? Hence you’re using bin convergence and replaces are not allowed on replaces as replace blindly overwrites the existing record. This can cause the loss of bin-level LUTs (Last update times) on older bins, thereby preventing convergence from working. Please see Bin convergence | Aerospike Documentation for more details, especially the section on “Record replace not allowed”.

Please let me know if there are any further questions.

2 Likes

This may help with what you are trying to do:

1 Like