Re: Redis EXPIRE problem

545 views
Skip to first unread message

Josiah Carlson

unread,
Jan 17, 2013, 12:04:16 PM1/17/13
to redi...@googlegroups.com
A ttl of -1 means that there does not currently exist an expiration
time on a key. That either means that the key doesn't exist or that it
doesn't have an expiration time. It is expected behavior.

For your keys that you watch their ttl drop to -1, try to fetch the
data once the ttl reaches -1, and notice that you don't get your data
back.

Regards,
- Josiah

On Wed, Jan 16, 2013 at 6:48 AM, Petridean Ovidiu <ullt...@gmail.com> wrote:
> Hi,
> I'm having a strange problem with redis.
> I have a master-slave configuration for redis.
> I set a number of keys(~1000) using a java app(with jedis) and they are
> supposed to expire in 24 hours since they have been set.
> The problem is that if if TTL looks ok for all the keys a small part of them
> do not expire.
> I wathed the TTL for the key decreasing to 0 and the it just gets to -1 and
> the key never expires.
> It is very strange that only a small number of those keys do not expire(this
> happnes randomly).
> I see no errors in redis log.
>
> I'm using redis 2.4.15.
>
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/redis-db/-/qH3J5rEKtXEJ.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/redis-db?hl=en.
Message has been deleted
Message has been deleted

Petridean Ovidiu

unread,
Feb 13, 2013, 7:12:17 AM2/13/13
to redi...@googlegroups.com
Hi,

Thanks for the reply.
That is exactly the problem, I do try to fetch data one the ttl reaches -1 and the data is still there.
As I said this is very strange as it only happens for a really small set of keys.
I am using a master-slave configuration, can this be a part of the problem? But I am not writing on the slave, as I know that this 
will cause keys to never expire.
Also persistence is disabled.

Thanks,
Ovidiu

Salvatore Sanfilippo

unread,
Feb 13, 2013, 8:48:19 AM2/13/13
to Redis DB
Hello,

it is almost surely a problem with your code and not with Redis,
probabilistically speaking, because expires are a very used/deployed
feature and we never received a single bug report like that.

So my guess is: you set the TTL with expire, but then later you call
"SET" against some of the keys, and the new value is set, and expire
removed. Maybe you assumed that once there is an expire set you can
set a new value and the expire is remembered? It works differently for
the SET command as SET is assignment to a new value completely.

Cheers,
Salvatore
> To unsubscribe from this group and stop receiving emails from it, send an
> email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/redis-db?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org

Beauty is more important in computing than anywhere else in technology
because software is so complicated. Beauty is the ultimate defence
against complexity.
— David Gelernter

Petridean Ovidiu

unread,
Feb 13, 2013, 8:58:43 AM2/13/13
to redi...@googlegroups.com
Hi,

I'm aware that SET overrides expiration, and that is not the case.
I only use INCR on keys.
Bu here's the funny thing.. I am monitoring the keys to see when they are close to the expiration time and I can se the TTL decreasing
until in reaches 0 and the it's set to -1.
If I've used SET or something wrong wouldn't that cause TTL to be set to -1 automatically when SET is called on a key?

Salvatore Sanfilippo

unread,
Feb 13, 2013, 9:01:07 AM2/13/13
to Redis DB
Are you setting keys on a slave instead of the master?

Petridean Ovidiu

unread,
Feb 13, 2013, 9:33:30 AM2/13/13
to redi...@googlegroups.com
No, the slave is used only for reading. And the behaviour can be seen on master, so that excludes the posibility to have set the keys on slave
as I wouldn't be able to see them on the master node.

Salvatore Sanfilippo

unread,
Feb 13, 2013, 11:40:41 AM2/13/13
to Redis DB
Ok, at this point I would suggest you the following, given that you
are able to follow keys with the odd behavior.
Track one of those, and try:

1) debug object 'keyname'
2) TTL to see the TTL decreasing, until it drops to -1
3) debug object 'keyname' again

Thanks,
Salvatore

Petridean Ovidiu

unread,
Feb 13, 2013, 12:59:59 PM2/13/13
to redi...@googlegroups.com
I will try that.

Thanks,
Ovidiu
Reply all
Reply to author
Forward
0 new messages