Redisキャッシュ サービスのメモリ オーバーフロー


説明

Redisキャッシュ サービスにおけるRAMの割り当てが不十分の場合にメモリ オーバーフローが発生し、Redisセッション状態プロバイダが新しいセッションを追加したり、または期限切れになったセッションを削除したりすることができなくなります。その結果、下記のエラーが出力され、ソリューションが完全にシャットダウンされます。

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

解決

Redisキャッシュ サービスに必要なRAM容量が割り当てられるかを確保する必要があります。必要なRAM容量を算出する方法については、次のドキュメントの「Estimate memory and storage requirements for session state」節に記載されているアプローチを参照してください。

現在選択されているRedisキャッシュの価格レベル(最大RAM容量)では必要なメモリ容量が不足している場合、Azureポータルでメモリ容量のスケーリングを実施することができます:Redisキャッシュ⇒Redisキャッシュを選択⇒すべての設定⇒価格レベル(スケーリングのセクション)