Open hn1 opened 1 year ago
I haven't tried using it with .NET 7, but it should work (and if it doesn't for some reason then I'd like to fix it)
So I've just run the unit tests locally targeting net7.0
and they all passed.
Are you able to provide a repro for this failure, or enable the RedLock logging and supply those?
Hi Thanks for responding. I am not sure how to configure and get log information from RedLock. If you point us in the right direction I will do so. Thanks
On Fri, Oct 6, 2023 at 12:13 PM Sam Cook @.***> wrote:
So I've just run the unit tests locally targeting net7.0 and they all passed.
Are you able to provide a repro for this failure, or enable the RedLock logging and supply those?
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1750435881, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2ONIFI7Y3M7BX5DRY3X57RV7AVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJQGQZTKOBYGE . You are receiving this because you authored the thread.Message ID: @.***>
Hi Is it possible to assist us in how to enable logging. We cannot find any docs on this feature. Thanks
Hi, to enable logging you need to pass an instance of ILoggerFactory
as a parameter when you create your RedLockFactory
Hi Have you any examples or any docs that shows this? Thanks
On Sun, Oct 8, 2023 at 11:32 PM Sam Cook @.***> wrote:
Hi, to enable logging you need to pass an instance of ILoggerFactory as a parameter when you create your RedLockFactory
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1752179183, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2ILD3KECI7MF3LF7NDX6MSXLAVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSGE3TSMJYGM . You are receiving this because you authored the thread.Message ID: @.***>
Nothing specifically documented, but you can see it in the tests (e.g. https://github.com/samcook/RedLock.net/blob/master/RedLockNet.Tests/RedLockTests.cs#L119).
You just need to get hold of an instance of ILoggerFactory
(e.g. from your DI container) and pass it to RedLockFactory.Create(endpoints, loggerFactory)
.
Thanks Sam. We'll give it a try and see if we can see anything that stops the lock in .NET7
On Mon, Oct 16, 2023 at 1:37 PM Sam Cook @.***> wrote:
Nothing specifically documented, but you can see it in the tests (e.g. https://github.com/samcook/RedLock.net/blob/master/RedLockNet.Tests/RedLockTests.cs#L119 ).
You just need to get hold of an instance of ILoggerFactory (e.g. from your DI container) and pass it to RedLockFactory.Create(endpoints, loggerFactory).
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1764383248, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2IHDNSL4EBMQMLGIGLX7UTAPAVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRUGM4DGMRUHA . You are receiving this because you authored the thread.Message ID: @.***>
Not related to .NET 7 but the lib fails at aquiring locks if StackExchange.Redis
is upgraded to any version later than 2.6.48
Creating the RedLockFactory by:
_factory = RedLockFactory.Create(connection, loggerFactory);
where connection is a List<RedLockEndPoint>
and each RedLockEndPoint has:
redLockEndPoint.EndPoints.Add(new DnsEndPoint("somehost", 6379));
redLockEndPoint.Password = "somepassword";
redLockEndPoint.RedisDatabase = 0;
redLockEndPoint.RedisKeyFormat = "someprefix:redlock:" + "{0}";
When StackExchange.Redis
is downgraded to 2.6.48, everything works as expected
Hi Sam, This is the log of Failing to get a lock with .7 AND .Net8. But works on .NET6. It keeps throwing this until the lock expires. Any ideas.? Thanks.
info: RedLockNet.SERedis.RedLock[0] Lock status: NoQuorum (Acquired: 0, Conflicted: 0, Error: 1), Demo:IE:HORboys-tU6U-dfDbic1lw (1de99336-c109-4be1-a10c-e92dc5d325d1)
info: RedLockNet.SERedis.RedLock[0] Lock status: NoQuorum (Acquired: 0, Conflicted: 0, Error: 1), Demo:IE:HORboys-tU6U-dfDbic1lw (0473cedf-f4fd-4053-8a31-9598c82ea070)
info: RedLockNet.SERedis.RedLock[0] Lock status: NoQuorum (Acquired: 0, Conflicted: 0, Error: 1), Demo:IE:HORboys-tU6U-dfDbic1lw (4432bb6f-a531-468a-9134-1b506550855d)
On Mon, Oct 16, 2023 at 2:08 PM H Nahavandi @.***> wrote:
Thanks Sam. We'll give it a try and see if we can see anything that stops the lock in .NET7
On Mon, Oct 16, 2023 at 1:37 PM Sam Cook @.***> wrote:
Nothing specifically documented, but you can see it in the tests (e.g. https://github.com/samcook/RedLock.net/blob/master/RedLockNet.Tests/RedLockTests.cs#L119 ).
You just need to get hold of an instance of ILoggerFactory (e.g. from your DI container) and pass it to RedLockFactory.Create(endpoints, loggerFactory).
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1764383248, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2IHDNSL4EBMQMLGIGLX7UTAPAVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRUGM4DGMRUHA . You are receiving this because you authored the thread.Message ID: @.***>
Would appreciate if you could let us know if this can be fixed or not so that we can adjust our application appropriately. Thanks
@hn1 Are you able to set the logging level to Debug
and capture the logs from a failed attempt to get a lock?
Also what version of RedLock.net and StackExchange.Redis are you using? And what OS/platform are you running on? What redis version or service are you running against?
Does increasing the ConnectionTimeout
property (e.g. to 1000ms) on the RedLockEndpoint
make any difference?
I have so far been unable to reproduce this issue with a console application targeting both net6.0
and net7.0
using the latest versions of RedLock.net and StackExchange.Redis, running on both windows and under Linux using WSL. If you're able to provide a simple example that reproduces the issue that would be very helpful.
Not related to .NET 7 but the lib fails at aquiring locks if
StackExchange.Redis
is upgraded to any version later than 2.6.48Creating the RedLockFactory by:
_factory = RedLockFactory.Create(connection, loggerFactory);
where connection is a
List<RedLockEndPoint>
and each RedLockEndPoint has:redLockEndPoint.EndPoints.Add(new DnsEndPoint("somehost", 6379)); redLockEndPoint.Password = "somepassword"; redLockEndPoint.RedisDatabase = 0; redLockEndPoint.RedisKeyFormat = "someprefix:redlock:" + "{0}";
When
StackExchange.Redis
is downgraded to 2.6.48, everything works as expected
@jonnepmyra I'm also unable to reproduce this, if you're able to provide a repro example could you open a new issue about it?
RedLock works perfectly on .NET6 - It is only after upgrading to .NET7 or .NET 8 that we have these issues. So the version numbers and OS should not be an issue as otherwise it would also not work on .NET6 which it does without any issues.
We are using the RedLock version 2.3.2We are also using the Microsoft.Extensions.Caching.StackExchangeRedis version 8.0.0 (for .NET 8)We are running on windows. Under the dependencies in RedLock we noticed StackExchange.Redis (2.6.122) - could this be the issue?
This is the Debug log:
info: RedLockNet.SERedis.RedLock[0] Lock status: NoQuorum (Acquired: 0, Conflicted: 0, Error: 1), Demo:IE:mCE02dmRHU6zKiqNDFXCJw (7f06e1b4-4118-4e42-be8c-8d4bf35f3ee1) dbug: RedLockNet.SERedis.RedLock[0] Disposing Demo:IE:mCE02dmRHU6zKiqNDFXCJw (7f06e1b4-4118-4e42-be8c-8d4bf35f3ee1) info: Microsoft.Azure.SignalR.DefaultServiceEventHandler[1] 4ad6c3e4-56f2-4846-bd9c-e26c04831ec1 recieved service event for Connection(CgsyB2wMG_aMvEPptEow5AuNsNbAh02) is NotExisted, message is: Connection 'CgsyB2wMG_aMvEPptEow5AuNsNbAh02' is not existed. dbug: RedLockNet.SERedis.RedLock[0] Error unlocking lock instance localhost:6379 (master, disconnected): The message timed out in the backlog attempting to send because no connection became available (1000ms) - Last Connection Exception: UnableToConnect on localhost:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 0s ago, last-write: 0s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.6.122.38350, command=EVAL, timeout: 1000, inst: 0, qu: 1, qs: 0, aw: False, bw: SpinningDown, rs: NotStarted, ws: Initializing, in: 0, last-in: 0, cur-in: 0, sync-ops: 2, async-ops: 12, serverEndpoint: localhost:6379, conn-sec: n/a, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: HN-LAPTOP(SE.Redis-v2.6.122.38350), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=2,Free=32765,Min=4,Max=32767), POOL: (Threads=16,QueuedItems=0,CompletedItems=7248,Timers=53), v: 2.6.122.38350 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
Thanks @hn1.
According to log message you posted, StackExchange.Redis is not able to connect to redis on localhost:6379
(which is why it's failing to acquire a lock). I'm assuming you have a redis server running there, if it works under .NET 6.0.
I updated my test application to use StackExchange.Redis 2.6.112 and it's still working just fine for me. 🤔
Are you able to make a sample project that reproduces the issue for you, which I'm able to run to try and see what the problem is?
That does not make sense as we are using the redis cache for all sorts of things without any issue in .NET6, .NET and .NET8.
That is definitely not it.
We have tried RedLock-cs and that works fine. So we will be using that for now.
Thanks
On Wed, Dec 6, 2023 at 9:35 PM Sam Cook @.***> wrote:
Thanks @hn1 https://github.com/hn1.
According to log message you posted, StackExchange.Redis is not able to connect to redis on localhost:6379 (which is why it's failing to acquire a lock). I'm assuming you have a redis server running there, if it works under .NET 6.0.
I updated my test application to use StackExchange.Redis 2.6.112 and it's still working just fine for me. 🤔
Are you able to make a sample project that reproduces the issue for you, which I'm able to run to try and see what the problem is?
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1843727121, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2IOBLPQQTMHT7R3VHTYIDQJXAVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBTG4ZDOMJSGE . You are receiving this because you were mentioned.Message ID: @.***>
That's unfortunate, if there is a problem with RedLock I'd like to figure out what it is, but without being able to reproduce it I'm not really able to get any further.
In your example you supplied the debug logs for, is your redis server running on localhost:6379
?
Yes it is. But Stackexchange is using the redis server all the time and its nothing to do with that. So it must be RedLock.
On Thu, Dec 7, 2023 at 1:11 AM Sam Cook @.***> wrote:
That's unfortunate, if there is a problem with RedLock I'd like to figure out what it is, but without being able to reproduce it I'm not really able to get any further.
In your example you supplied the debug logs for, is your redis server running on localhost:6379?
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1843971252, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2I5WSKNQ76YXGMBJHDYIEJVDAVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBTHE3TCMRVGI . You are receiving this because you were mentioned.Message ID: @.***>
How are you initialising the RedLockFactory
?
Can you show the configuration you're passing to RedLockFactory.Create()
?
I'm using RedLock in .Net 5, .Net 6, .Net7 and .Net8 without problem. I have not have any problem with different versions of SE.Redis either in any of the dotnet version and combinations.
What I have seen is in other communications is that resolution of hostname localhost
some times is resolved to the IP4 address and sometimes to the IP6 address and to get around that the usage of IP directly has solved the problem.
Will you have the same problem if you using the IP address insted of hostname?
WOW. WELL DONE. It works. Thank you so much for your help.
On Thu, Dec 7, 2023 at 6:37 AM Patric Forsgard @.***> wrote:
I'm using RedLock in .Net 5, .Net 6, .Net7 and .Net8 without problem. I have not have any problem with different versions of SE.Redis either in any of the dotnet version and combinations.
What I have seen is in other communications is that resolution of hostname localhost some times is resolved to the IP4 address and sometimes to the IP6 address and to get around that the usage of IP directly has solved the problem.
Will you have the same problem if you using the IP address insted of hostname?
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1844750453, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2JP5RY33U2CO26PMPDYIFPZJAVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBUG42TANBVGM . You are receiving this because you were mentioned.Message ID: @.***>
Interesting, thanks for the suggestion @Tasteful.
@hn1 out of interest, we're you using your own instances of ConnectionMultiplexer with RedLock.net, or were you letting it establish its own connection?
This is how we are initializing it:
services.AddSingleton<IDistributedLockFactory, RedLockFactory>(
x => RedLockFactory.Create(
new List
EndPoint = new System.Net.DnsEndPoint("127.0.0.1", 6379),
Password = ""
}
}
));
Does this help?
On Thu, Dec 7, 2023 at 7:02 AM Sam Cook @.***> wrote:
Interesting, thanks for the suggestion @Tasteful https://github.com/Tasteful.
@hn1 https://github.com/hn1 out of interest, we're you using your own instances of ConnectionMultiplexer with RedLock.net, or were you letting it establish its own connection?
— Reply to this email directly, view it on GitHub https://github.com/samcook/RedLock.net/issues/104#issuecomment-1844784327, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA6J2J5VGT6HBAOBYKQ3NTYIFSZPAVCNFSM6AAAAAA5UMMG4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBUG44DIMZSG4 . You are receiving this because you were mentioned.Message ID: @.***>
When we upgrade from .NET6 to .NET7, RedLock fails to obtain locks. Is .NET7 supported? Thanks