Aerospike systematically storing wrong values

Here’s what I get from AQL “last_life_ts” and “lives” contain total nonsense, and I have no idea why.

Here’s what I send through the PHP client :

    $user = array();

    $ts = time();
    $user['diamonds'] = 30;
    $user['last_life_ts'] = $ts;
    $user['lives'] = 5;
    $user['last_reward_ts'] = $ts;
    $user['save_time'] = $ts;
    $user['version'] = 0;

    $key = $client->initKey($ns, $set, $key_name);

    $status = $client->put($key, $user);

And this is deterministic. No matter how many time I delete the record and write it again, I always get this result. I’m using aerospike-server-community-3.5.15 and the PHP client 3.4.0, although I doubt the problem comes from the client…

Thanks in advance

What version of the aerospike-tools package are you running?

This could be an AQL bug, what does php return when you read this record?

Your server version, 3.5.15, is an older release, are you able to reproduce this issue on 3.10.0.3?

The value shown in ‘last_life_ts’ suggests that it’s getting serialized, but I’m not sure why that’s happening. In theory, the client should only serialize unsupported types, then store them as as_bytes encoded as AS_BYTES_PHP. On the get() the PHP client will identify such values and deserialize them. However, a call to time() should be a integer, which should not be serialized. It’s also odd that other fields assigned with $ts didn’t get similarly serialized.

However your code snippet does not show this behavior with the CE 3.9.1 server and PHP client version 3.4.7 (my PHP version is 5.6.11). I used your code snippet, and this is what I see in AQL (version 3.8.3):

aql> select * from test.demo
+----------+--------------+-------+----------------+------------+---------+
| diamonds | last_life_ts | lives | last_reward_ts | save_time  | version |
+----------+--------------+-------+----------------+------------+---------+
| 30       | 1478827634   | 5     | 1478827634     | 1478827634 | 0       |
+----------+--------------+-------+----------------+------------+---------+
1 row in set (0.021 secs)

Start with upgrading to the latest PHP client, currently at release 3.4.13. I’d also suggest you use the appropriate AQL version. When you’re ready, upgrade the server version, as well.

Finally found the reason why it happened… Further in the code, lives and life_time_ts are updated, and because of some weird PHP semantic, the values were stored as floats. Apparently, AS doesn’t like floats…

Double precision floats were added in 3.6.0.

@kicker, you’re using a PHP client and Aerospike CE server from 21 months ago. Time for an upgrade on both ends. Support for doubles (float) was in the client since 3.4.3 (October 2015) and in the server since 3.6.0 (August 2015).

It seems so. Thanks for the replies.