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

.NET 7 support #104

Open
hn1 opened this issue Oct 5, 2023 · 23 comments
Open

.NET 7 support #104

hn1 opened this issue Oct 5, 2023 · 23 comments

Comments

@hn1
Copy link

hn1 commented Oct 5, 2023

When we upgrade from .NET6 to .NET7, RedLock fails to obtain locks.
Is .NET7 supported?
Thanks

@samcook
Copy link
Owner

samcook commented Oct 6, 2023

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)

@samcook
Copy link
Owner

samcook commented Oct 6, 2023

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?

@hn1
Copy link
Author

hn1 commented Oct 6, 2023 via email

@hn1
Copy link
Author

hn1 commented Oct 8, 2023

Hi
Is it possible to assist us in how to enable logging. We cannot find any docs on this feature.
Thanks

@samcook
Copy link
Owner

samcook commented Oct 8, 2023

Hi, to enable logging you need to pass an instance of ILoggerFactory as a parameter when you create your RedLockFactory

@hn1
Copy link
Author

hn1 commented Oct 10, 2023 via email

@samcook
Copy link
Owner

samcook commented Oct 16, 2023

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).

@hn1
Copy link
Author

hn1 commented Oct 16, 2023 via email

@jonnepmyra
Copy link

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

@hn1
Copy link
Author

hn1 commented Dec 1, 2023 via email

@hn1
Copy link
Author

hn1 commented Dec 5, 2023

Would appreciate if you could let us know if this can be fixed or not so that we can adjust our application appropriately.
Thanks

@samcook
Copy link
Owner

samcook commented Dec 6, 2023

@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.

@samcook
Copy link
Owner

samcook commented Dec 6, 2023

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

@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?

@hn1
Copy link
Author

hn1 commented Dec 6, 2023

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)

@samcook
Copy link
Owner

samcook commented Dec 6, 2023

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?

@hn1
Copy link
Author

hn1 commented Dec 7, 2023 via email

@samcook
Copy link
Owner

samcook commented Dec 7, 2023

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?

@hn1
Copy link
Author

hn1 commented Dec 7, 2023 via email

@samcook
Copy link
Owner

samcook commented Dec 7, 2023

How are you initialising the RedLockFactory?

Can you show the configuration you're passing to RedLockFactory.Create()?

@Tasteful
Copy link

Tasteful commented Dec 7, 2023

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?

@hn1
Copy link
Author

hn1 commented Dec 7, 2023 via email

@samcook
Copy link
Owner

samcook commented Dec 7, 2023

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?

@hn1
Copy link
Author

hn1 commented Dec 7, 2023 via email

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

4 participants