Repository navigation
Description
We are using the https://github.com/Azure/aspnet-redis-providers for session state. Somehow our sentinel server will enter the TILT mode and during this time the https://github.com/StackExchange/StackExchange.Redis/blob/6409b9d1f2afd01a7eab9498a525360d1ca2b752/src/StackExchange.Redis/ConnectionMultiplexer.cs#L2354 is throwing NotImplementedException (why use this exception?). The NotImplementedException is not handled correctly in the session state provider with the result that the exception will be stuck in an Lazy<> (see below stack trace) and returned for all future executions until IIS is reset.
If we can change the NotImplementedException to an RedisConnectionException the session state provider will catch and try to reconnect.
The ConnectionMultiplexer is not a Sentinel connection. System.NotImplementedException
at StackExchange.Redis.ConnectionMultiplexer.GetSentinelMasterConnection(ConfigurationOptions config, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2362
at StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1034
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at Microsoft.Web.Redis.RedisSharedConnection.get_Connection() in C:\TeamCity\buildAgent\work\59b31e8e4035fd30\src\Shared\RedisSharedConnection.cs:line 71
at Microsoft.Web.Redis.StackExchangeClientConnection.<>c__DisplayClass7_0.<Eval>b__0() in C:\TeamCity\buildAgent\work\59b31e8e4035fd30\src\Shared\StackExchangeClientConnection.cs:line 68
at Microsoft.Web.Redis.StackExchangeClientConnection.OperationExecutor(Func`1 redisOperation) in C:\TeamCity\buildAgent\work\59b31e8e4035fd30\src\Shared\StackExchangeClientConnection.cs:line 95
at Microsoft.Web.Redis.StackExchangeClientConnection.RetryLogic(Func`1 redisOperation) in C:\TeamCity\buildAgent\work\59b31e8e4035fd30\src\Shared\StackExchangeClientConnection.cs:line 122
at Microsoft.Web.Redis.StackExchangeClientConnection.Eval(String script, String[] keyArgs, Object[] valueArgs) in C:\TeamCity\buildAgent\work\59b31e8e4035fd30\src\Shared\StackExchangeClientConnection.cs:line 68
at Microsoft.Web.Redis.RedisConnectionWrapper.Set(ISessionStateItemCollection data, Int32 sessionTimeout) in C:\TeamCity\buildAgent\work\59b31e8e4035fd30\src\RedisSessionStateProvider\RedisConnectionWrapper.cs:line 137
at Microsoft.Web.Redis.RedisSessionStateProvider.<SetAndReleaseItemExclusiveAsync>d__25.MoveNext() in C:\TeamCity\buildAgent\work\59b31e8e4035fd30\src\RedisSessionStateProvider\RedisSessionStateProvider.cs:line 433
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.SessionState.SessionStateModuleAsync.<ReleaseStateAsyncImpl>d__80.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.SessionState.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Activity
Victor-Tseng commentedon Mar 2, 2021
Hi, we are trying to use 2.1.58 which has Sentinel mode support. But we are also using the Redis Session State provider and this issue is a concern to us. I am wondering if this fix will be released soon or not. Any idea?
Tasteful commentedon Mar 2, 2021
@Victor-Tseng To get around the problem you can let the SR.Redis connect to all the redis host, then the SR.Redis will figure out the primary nodes automatic. This will create more administration when adding or removing redis host because all connection strings need to be updated with the correct host information.
Victor-Tseng commentedon Mar 8, 2021
@Tasteful Thank you for the workaround, but the purpose of using Sentinel mode is to get rid of such connection string management, especially for the scenario of adding/removing Redis nodes on the fly. We will wait for the next release.
Victor-Tseng commentedon Nov 1, 2021
@Tasteful By the way could you provide more details about how to reproduce the issue? For example for a cluster with 3 sentinels do I need to make all sentinels into TILT mode or just one of them will do?
Tasteful commentedon Nov 1, 2021
@Victor-Tseng I don't have any steps that can be used to get the sentinel into TILT mode but if we read the documentation https://redis.io/topics/sentinel you have a section about TILT mode in the end.
In our setup we have a load balancer in front of the sentinel, the client was connecting to the load balancer forwarded the request round robin to the sentinel servers. If the connection entered an sentinel server that was in TITL mode the request for
SENTINEL get-master-addr-by-name mymaster-command the server was responding with something like "command not found" and theNotImplementedExceptionwas thrown by this library that not was handled correctly in the asp.net redis session state provider.This have been fixed in this library in later releases so please update to get this to work correctly.
Update: Can see the linked issue that you still have problem with the later release in the linked issue, we have changed to let SE.Redis connect to all Redis-instances and by them self figure out the master node and have not have any connection problem after that..
sachin27sharma commentedon Apr 8, 2022
Hi,
Am having similar issue and want more clarity.
I was trying to use a Load Balancer hostname, which sits in front of 3 sentinels and using service name for sentinel master in ConfigurationOptions.
Error - Message: Sentinel: The ConnectionMultiplexer is not a Sentinel connection. Detected as: Standalone
If I specify IP of all the 3 sentinel as connection end point, then Redis connection works fine.
How can I use Load Balancer, instead of setting sentinels server directly ?
Thanks