# Aerospike systematically storing wrong values

**URL:** <https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595>\
**Category:** General Discussion\
**Created:** [November 10, 2016, 11:25pm UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595 "2016-11-10T23:25:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kicker](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@Kicker](https://discuss.aerospike.com/u/Kicker)\
**Post date:** [November 10, 2016, 11:25pm UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595/1 "2016-11-10T23:25:05Z")

</div>

Here’s what I get from AQL [![](https://i.imgur.com/PDV7506.png) ](https://i.imgur.com/PDV7506.png) “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

---

<div class="post-metadata">

**Author:** ![kporter](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/kporter/32/515_2.png) [@kporter](https://discuss.aerospike.com/u/kporter)\
**Post date:** [November 11, 2016, 1:09am UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595/2 "2016-11-11T01:09:04Z")

</div>

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](http://www.aerospike.com/download/server/notes.html#3.5.15), is an older release, are you able to reproduce this issue on [3.10.0.3](http://www.aerospike.com/download/server/notes.html#3.10.0.3)?

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [November 11, 2016, 1:29am UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595/3 "2016-11-11T01:29:24Z")

</div>

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](https://github.com/aerospike/aerospike-client-php/blob/master/doc/README.md#handling-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):

```auto
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](https://github.com/aerospike/aerospike-client-php/releases). I’d also suggest you use the appropriate AQL version. When you’re ready, upgrade the server version, as well.

---

<div class="post-metadata">

**Author:** ![Kicker](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@Kicker](https://discuss.aerospike.com/u/Kicker)\
**Post date:** [November 11, 2016, 1:42am UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595/4 "2016-11-11T01:42:41Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![kporter](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/kporter/32/515_2.png) [@kporter](https://discuss.aerospike.com/u/kporter)\
**Post date:** [November 11, 2016, 1:46am UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595/5 "2016-11-11T01:46:57Z")

</div>

> [@Kicker](#):
>
> Apparently, AS doesn’t like floats…

Double precision floats were added in [3.6.0](http://www.aerospike.com/download/server/notes.html#3.6.0).

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [November 11, 2016, 2:00am UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595/6 "2016-11-11T02:00:46Z")

</div>

@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).

---

<div class="post-metadata">

**Author:** ![Kicker](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@Kicker](https://discuss.aerospike.com/u/Kicker)\
**Post date:** [November 14, 2016, 9:39pm UTC](https://discuss.aerospike.com/t/aerospike-systematically-storing-wrong-values/3595/7 "2016-11-14T21:39:09Z")

</div>

It seems so. Thanks for the replies.
