Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LockTimeout value #19

Open
craigvn opened this issue May 24, 2016 · 1 comment
Open

LockTimeout value #19

craigvn opened this issue May 24, 2016 · 1 comment

Comments

@craigvn
Copy link

craigvn commented May 24, 2016

I notice the default LockTimeout value is 30 seconds. Is this the time it will attempt to retrieve a value from Redis before failing? Most of my requests take less than 25ms so would it be safe to make this something like 1 or 2 seconds? The reason being that I am using Redis on Azure and it periodically has connection issues which I would prefer to fail quickly on rather than wait.

@TheCloudlessSky
Copy link
Owner

The LockTimeout is how long NHibernate should hold onto the lock. By default, it's a large number of seconds to account for any problems. It's the upper bound of your transaction duration. It's definitely safe to make it 1-2 seconds. However, you need to ensure everything else occurs within the lock timeout as well (e.g. what's your DB timeout?). A possible worst case scenario is:

  1. A lock is taken.
  2. Some sort stall during your request causing the lock to timeout (e.g. DB connection, network latency etc)
  3. A concurrent transaction takes a lock (because the other lock timed out).
  4. The original transaction tries to free the lock, but it doesn't own it anymore (thus triggering the RedisCacheProviderOptions.OnUnlockFailed... which may throw an exception depending on how you have it configured).

The default is very high to simply account for these scenarios, but it could be any value depending on your application's requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants