I'm having hard time understanding the following from AeroSpike documentation:
http://www.aerospike.com/docs/client/python/usage/kvs/record-structure.html
A record also has two metadata values associated with it - the record generation (the number of times it has been modified) and its ttl. A ttl can be set to the numbers of second remaining till it is considered expired, or to 0 (for 'never expire', and the default). Records whose ttl has expired will be garbage collected by the server. Each time the record is written or touched (using touch()) its ttl will reset.
My initial thought was that if namespace policy default ttl is set to 0 then the records will not expire.
My Aerospike namespace configuration is the following :
namespace brand {
replication-factor 2
memory-size 4G
default-ttl 0 # 30 days, use 0 to never expire/evict.
storage-engine memory
# To use file storage backing, comment out the line above and use the
# following lines instead.
set twitter {
set-disable-eviction true
}
storage-engine device {
file /opt/aerospike/data/bar.dat
filesize 16G
data-in-memory true # Store data in memory in addition to file.
}
}
I made a few inserts into the database, then when I retrieved the data I got the following :
{ name: 'test',
twitter: 'test',
domain: 'test.com',
description: 'Your First Round Fund' } { ttl: 4294967295, gen: 2 }
Somehow a ttl appeared on the record and other records have a ttl also. I don't want my records to be deleted from the database. How can I remove the ttl from the records and how can I prevent this from happening in the future?
"asadm -e 'show stat like ttl'
Shows the following:
~~~~brand Namespace Statistics~~~~
NODE : 1
cold-start-evict-ttl: 4294967295
default-ttl : 0
max-ttl : 0
~~~~test Namespace Statistics~~~~~
NODE : 1
cold-start-evict-ttl: 4294967295
default-ttl : 2592000
max-ttl : 0
asinfo -v 'hist-dump:ns=brand;hist=ttl'
Shows the following
brand:ttl=100,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
The node.js get operations meta information is displaying { ttl: 4294967295, gen: 2 }.
Alright! So the TTL unsigned 32 bit integer, you are seeing the maximum value of (2^32 -1) if it were a signed int it would be -1. The max value has special meaning in Aerospike and it means that it lives indefinitely. Aerospike has accepted -1 as indefinite for about a year now and 0 from the client means use server default.
The node.js client is based on our c client which was changed to convert ttl 0 values from the server to 0xFFFFffff or -1. This was mentioned in the c client's 3.0.51 release notes.
Thanks for highlighting this issue, looks like there are some stale docs around this area.