Open alexandrepepin-boxoffice opened 4 months ago
@alexandrepepin-boxoffice the redis lock has a default expiry of 30s (with regular renewal so long as the lock is held). See these docs.
So I would expect that if you lose connection to your Redis instance the lock would be held for no more than 30s.
You can shorten that time by fiddling with the options, but if you make it too short then you risk losing the lock spuriously due to lack on your app server (app server is too overloaded to renew the lease before it expires).
I'm also curious whether you think the timeouts themselves are strange: is this something that happens rarely and when it does other unrelated Redis requests also time out or is this something that happens every time and only when the library is trying to release?
Timeouts aren't strange, they happen rarely and they happen in combination with other unrelated redis requests. I wanted to understand how to recover from those errors. If the default expiry is 30s and configurable, that perfectly fits our needs
I'm going to consider this resolved for the time being. It would be great if we had a way to ensure that the lock renewal system was not affected by thread starvation, but that seems difficult especially since StackExchange.Redis itself is async under the hood and might use the default thread pool even if we make efforts not too. So I think for now the guidance should be to set a longer expiry if you plan to exhaust the thread pool, or better yet don't exhaust the thread pool :-).
We are sometime getting timeouts on releasing the redis lock. What's the best way to handle this so that the lock can be freed up and not stay lock forever
Exception: