Play-redis timeouts after a few days


(Chaitanya Anpat) #1

I have integrated Redis in my application as a cache. In application.config I have enabled play-redis module:

play.modules.enabled += "play.api.cache.redis.RedisCacheModule"

I have configured max memory = 1gb and memory policy to allkeys-lru (remove any key according to the LRU algorithm) in Redis config file. So when Redis cache reaches to 1gb, old keys will be removed and new data can be inserted.

Redis cache with works fine for 5-6 days but after that, it throws receive timeouts errors. After app restart, Redis is also restarted and cache gets flushed and does not get the error.

The exact error is:

[error] s.i.ListenerActor - Receive timeout
[error] p.a.cache.redis - Command GET classTag::_cursor_UPDATE_VALUE_timoncool for key 'GET' failed.
scredis.exceptions.RedisIOException: Receive timeout to localhost/127.0.0.1:6379
	at scredis.io.ListenerActor$$anonfun$reconnecting$1.applyOrElse(ListenerActor.scala:414)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:171)
	at akka.actor.Actor$class.aroundReceive(Actor.scala:497)
	at scredis.io.ListenerActor.aroundReceive(ListenerActor.scala:27)
	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
	at akka.actor.dungeon.DeathWatch$class.receivedTerminated(DeathWatch.scala:46)
	at akka.actor.ActorCell.receivedTerminated(ActorCell.scala:374)
	at akka.actor.ActorCell.autoReceiveMessage(ActorCell.scala:511)
	at akka.actor.ActorCell.invoke(ActorCell.scala:494)

Does this mean some thread is unable to connect localhost/127.0.0.1:6379 (on this port Redis is running)? As the application could not connect to Redis, the method GET fails.

What is the exact cause of the timeout issue? How to resolve the issue? Any links to refer?


(Marcos Pereira) #2

Hi @chaitanya.anpat,

Hard to say what may be causing the timeout. I would suggest to:

  1. Use DEBUG log level for play-redis and scredis classes and see if this helps to have more information about the exception.
  2. When the timeout happens, try to connect to redis using redis-cli just to confirm the redis server is up and running.

By the way, which version of play-redis are you using?

Best.


(Aditya Athalye) #3

@chaitanya.anpat Is there a possibility, that you are trying to open more connections than can be supported by the Redis server (inadvertently)? Redis logs during that time might also help diagnosing the issue.

Cheers
Aditya


(Chaitanya Anpat) #4

Redis keeps running but operations like SET data or GET data in cache, shows the error I mentioned.


(Chaitanya Anpat) #5

More connections might be the cause. I have mentioned how logs are printed. I did not find the cause of “scredis.exceptions.RedisIOException: Receive timeout to localhost”


(Aditya Athalye) #6

You need to check the logs on Redis Server (since it is local). My logs exist in /usr/local/var/log/redis.log. It might provide you some info on number of open connections.


(Chaitanya Anpat) #7

Thanks.I Will check and get back. Actually log file is empty.


(Chaitanya Anpat) #8

I posted this question on scredis git repo. He said that version on play-redis is older. How to update it?


(Marcos Pereira) #9

There is a compatibility matrix here:

Meaning you should use a version that is compatible with Play version your project is using. The docs for the most recent version of play-redis are here:

Best.


(Chaitanya Anpat) #10

Thanks a lot, I will aply changes.