drachtio-siprec-recording-server icon indicating copy to clipboard operation
drachtio-siprec-recording-server copied to clipboard

redis entries are not deleted

Open aks-zero opened this issue 5 years ago • 5 comments

Hi, I use this application with Freeswitch. Entries created in the redis server are not deleted and stay forever even after the SIPREC call is terminated with BYE gracefully. It seems it's happening all the time. Will appreciate any help for this. Thanks in advance.

aks-zero avatar Apr 27 '20 08:04 aks-zero

The redis keys are inserted with an expiry of 10 seconds, here

Therefore, they should disappear after 10 seconds. Perhaps the latter set request is somehow eliminating this expires value. Not sure, I will have to look into it

davehorton avatar Apr 27 '20 11:04 davehorton

could you do a test for me?

Try changing this line

from

.set(sessionId, sdp)

to

.set(sessionId, sdp, 'KEEPTTL')

and see if that fixes it?

davehorton avatar Apr 27 '20 11:04 davehorton

You are right. I never see any TTL on the key as if it wasn't never set (it always returns -1). As you mentioned, I think the latter SET request is discarding the expiry value. From the Redis documetation:

Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.

Since the KEEPTTL is supported only in Redis >= 6.0, I couldn't test. Will try after upgrading Redis.

Alternatively, may be we can set the the expiry again during the second call using 'SET EX' option or 'SETEX' command.

aks-zero avatar Apr 27 '20 19:04 aks-zero

yes, you could just replicate the set ex command as used earlier. Try that -- if it works let me know. Feel free to make a PR

davehorton avatar Apr 27 '20 21:04 davehorton

Yes, that worked. Thanks a lot.

127.0.0.1:6379> KEYS *
1) "2fb147ed-549f-4ecf-aae0-0f9444cf9bb0"
127.0.0.1:6379> 
127.0.0.1:6379> ttl 2fb147ed-549f-4ecf-aae0-0f9444cf9bb0
(integer) 3
127.0.0.1:6379> 
127.0.0.1:6379> ttl 2fb147ed-549f-4ecf-aae0-0f9444cf9bb0
(integer) 0
127.0.0.1:6379> 
127.0.0.1:6379> ttl 2fb147ed-549f-4ecf-aae0-0f9444cf9bb0
(integer) -2
127.0.0.1:6379> 
127.0.0.1:6379> KEYS *
(empty list or set)
127.0.0.1:6379> 

aks-zero avatar Apr 28 '20 01:04 aks-zero