Redis cache service memory overflow

  • If the Redis cache service did not allocate enough RAM, the Redis session state provider fails to add new sessions and remove the expired ones due to memory overflow. As a result, the solution permanently shuts down with the following YSOD:

    Server Error in '/' Application.
    ERR Error running script (call to f_f61bd104cdd24acf438fe02407a37f4334659383): @user_script:4: @user_script: 4: -OOM command not allowed when used memory > 'maxmemory'.   
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: StackExchange.Redis.RedisServerException: ERR Error running script (call to f_f61bd104cdd24acf438fe02407a37f4334659383): @user_script:4: @user_script: 4: -OOM command not allowed when used memory > 'maxmemory'.   

    Source Error: 
    An unhandled exception was generated during the execution of the current web request. The information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:  
    [RedisServerException: ERR Error running script (call to f_f61bd104cdd24acf438fe02407a37f4334659383): @user_script:4: @user_script: 4: -OOM command not allowed when used memory > 'maxmemory'.   ]
       StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl(Message message, ResultProcessor`1 processor, ServerEndPoint server) +2901
       StackExchange.Redis.RedisBase.ExecuteSync(Message message, ResultProcessor`1 processor, ServerEndPoint server) +122
       StackExchange.Redis.RedisDatabase.ScriptEvaluate(String script, RedisKey[] keys, RedisValue[] values, CommandFlags flags) +279
       Sitecore.SessionProvider.Redis.<>c__DisplayClass7.<Eval>b__6() +55
       Sitecore.SessionProvider.Redis.StackExchangeClientConnection.RetryForScriptNotFound(Func`1 redisOperation) +135
       Sitecore.SessionProvider.Redis.StackExchangeClientConnection.RetryLogic(Func`1 redisOperation) +144
       Sitecore.SessionProvider.Redis.StackExchangeClientConnection.Eval(String script, String[] keyArgs, Object[] valueArgs) +542
       Sitecore.SessionProvider.Redis.RedisConnectionWrapper.TryTakeWriteLockAndGetData(String sessionId, DateTime lockTime, Object& lockId, ISessionStateItemCollection& data, Int32& sessionTimeout) +356
       Sitecore.SessionProvider.Redis.RedisSessionStateProvider.GetItemFromSessionStore(Boolean isWriteLockRequired, HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) +1129
       Sitecore.SessionProvider.Redis.RedisSessionStateProvider.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) +232
       System.Web.SessionState.SessionStateModule.GetSessionStateItem() +176
       System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +980
       System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +636
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157
  • Enough RAM should be allocated for the Redis cache service. Approximately needed RAM can be calculated using the approach described in the storage requirements article.

    If currently selected Redis cache tier (max RAM) does not provide the needed amount of memory, it can be scaled to a bigger one using the Azure portal: Redis Caches -> Select a Redis cache -> All settings -> Pricing tier (Scale section).

Applies to:

Azure 8.0+

November 16, 2016
November 20, 2019

Reference number:

122173

Keywords: 

  • Azure