Closed miaoyukai closed 2 years ago
version 2.1.0
One of the machines will report IsAcquired == false
if the other is holding the lock, and it isn't able to obtain it within the wait time (3 seconds in your example code above). However I wouldn't expect that this should happen every single time unless the lock truly is being held each time by the other machine.
You best options here are to check the value of Status
and InstanceSummary
properties for a bit more detailed information about why the lock wasn't able to be obtained.
If that doesn't help, you'll need to wire up a logger in the RedLockFactory.Create
method (it takes an optional ILoggerFactory
) and get some logs to find out exactly what is happening.
One of the machines will report
IsAcquired == false
if the other is holding the lock, and it isn't able to obtain it within the wait time (3 seconds in your example code above). However I wouldn't expect that this should happen every single time unless the lock truly is being held each time by the other machine.You best options here are to check the value of
Status
andInstanceSummary
properties for a bit more detailed information about why the lock wasn't able to be obtained.If that doesn't help, you'll need to wire up a logger in the
RedLockFactory.Create
method (it takes an optionalILoggerFactory
) and get some logs to find out exactly what is happening.
thank you
One of the machines will report
IsAcquired == false
if the other is holding the lock, and it isn't able to obtain it within the wait time (3 seconds in your example code above). However I wouldn't expect that this should happen every single time unless the lock truly is being held each time by the other machine.You best options here are to check the value of
Status
andInstanceSummary
properties for a bit more detailed information about why the lock wasn't able to be obtained.If that doesn't help, you'll need to wire up a logger in the
RedLockFactory.Create
method (it takes an optionalILoggerFactory
) and get some logs to find out exactly what is happening.
hello. Now I recorded the error log as follows: IsAcquired:False, Status:NoQuorum, InstanceSummary.Acquired:0; InstanceSummary.Error:1; InstanceSummary.Conflicted:0; key:u_u100676462:s_021_aa95833:2020-09-22
One of the machines will report
IsAcquired == false
if the other is holding the lock, and it isn't able to obtain it within the wait time (3 seconds in your example code above). However I wouldn't expect that this should happen every single time unless the lock truly is being held each time by the other machine. You best options here are to check the value ofStatus
andInstanceSummary
properties for a bit more detailed information about why the lock wasn't able to be obtained. If that doesn't help, you'll need to wire up a logger in theRedLockFactory.Create
method (it takes an optionalILoggerFactory
) and get some logs to find out exactly what is happening.
I am a single Redis server
So the information you've provided there shows that an exception occurred while trying to acquire the lock with your redis server.
To find out exactly what that error is you'll need to inject an instance of ILoggerFactory
in your RedLockFactory.Create
call. From your example code it looks like you're using NLog, I believe the NLog.Extensions.Logging
package has what you need to wire that up.
Once you have logs from RedLock, you should see something like Error locking lock instance {host}: {message}
at the Debug
log level.
So the information you've provided there shows that an exception occurred while trying to acquire the lock with your redis server.
To find out exactly what that error is you'll need to inject an instance of
ILoggerFactory
in yourRedLockFactory.Create
call. From your example code it looks like you're using NLog, I believe theNLog.Extensions.Logging
package has what you need to wire that up.Once you have logs from RedLock, you should see something like
Error locking lock instance {host}: {message}
at theDebug
log level.
I don't use .net core now
That shouldn't matter, it supports .NET Framework as well
As the problem description.code show as below
use
After running for a period of time, one of the machines will always become false.Restart the IIS application pool of that machine