Search code examples
c#asp.net-mvc-3azureazure-caching

Azure Session Cache Error


I've started getting an Azure Cache Error thrown repeatedly. It appears to be to do with expired sessions. This is a random sample - it happens for static files.

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 10/25/2012 9:49:15 AM 
Event time (UTC): 10/25/2012 9:49:15 AM 
Event ID: 004e617f16854e59b7a857ca542ae9fc 
Event sequence: 86004 
Event occurrence: 720 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1273337584/ROOT-1-129955415508042441 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: E:\sitesroot\0\ 
    Machine name: RD00155D36A377 

Process information: 
    Process ID: 3332 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: DataCacheException 
    Exception message: ErrorCode:SubStatus:Key referred to does not exist. Create objects based on a Key to fix the error.
   at Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody)
   at Microsoft.ApplicationServer.Caching.DataCache.ExecuteAPI(RequestBody reqMsg, IMonitoringListener listener)
   at Microsoft.ApplicationServer.Caching.DataCache.InternalResetObjectTimeout(String key, TimeSpan newTimeout, String region, IMonitoringListener listener)
   at Microsoft.ApplicationServer.Caching.DataCache.c__DisplayClass68.b__67()
   at Microsoft.ApplicationServer.Caching.DataCache.ResetObjectTimeout(String key, TimeSpan newTimeout)
   at Microsoft.Web.DistributedCache.DataCacheRetryWrapper.PerformCacheOperation(Action action)
   at Microsoft.Web.DistributedCache.DataCacheForwarderBase.ResetObjectTimeout(String key, TimeSpan newTimeout)
   at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)



Request information: 
    Request URL: http://www.beko.co.uk/Scripts/jquery.nivo.slider.pack.js 
    Request path: /Scripts/jquery.nivo.slider.pack.js 
    User host address: 80.2.72.81 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 11 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    Stack trace:    at Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody)
   at Microsoft.ApplicationServer.Caching.DataCache.ExecuteAPI(RequestBody reqMsg, IMonitoringListener listener)
   at Microsoft.ApplicationServer.Caching.DataCache.InternalResetObjectTimeout(String key, TimeSpan newTimeout, String region, IMonitoringListener listener)
   at Microsoft.ApplicationServer.Caching.DataCache.c__DisplayClass68.b__67()
   at Microsoft.ApplicationServer.Caching.DataCache.ResetObjectTimeout(String key, TimeSpan newTimeout)
   at Microsoft.Web.DistributedCache.DataCacheRetryWrapper.PerformCacheOperation(Action action)
   at Microsoft.Web.DistributedCache.DataCacheForwarderBase.ResetObjectTimeout(String key, TimeSpan newTimeout)
   at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

There is no code around this, it is configured in web.config

<dataCacheClients>
  <dataCacheClient name="default">
    <hosts>
      <host name="[mycachename]" cachePort="22233" />
    </hosts>
    <securityProperties mode="Message">
      <messageSecurity authorizationInfo="[mykey]"></messageSecurity>
    </securityProperties>
  </dataCacheClient>
  <dataCacheClient name="SslEndpoint">
    <hosts>
      <host name="[mycachename]" cachePort="22243" />
    </hosts>
    <securityProperties mode="Message" sslEnabled="true">
      <messageSecurity authorizationInfo="[mykey]"></messageSecurity>
    </securityProperties>
  </dataCacheClient>
</dataCacheClients>

Edit: session state is configure as follows:

<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
  <providers>
    <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" useBlobMode="true" dataCacheClientName="default" />
  </providers>
</sessionState>

I'm trying to understand if there is a) Anything I can do to fix this in config b) Which DLL's are involved, and what is the latest version, (so I can see if updating helps) c) If anyone else is seeing this.

It started after I did quite a few application updates, and also updated the cache size in Azure. Not sure therefore what the cause was. I wouldn't have thought code changes were responsible, but its possible we have updated some DLL as one of the PC's we have used in the dev processes was newly built.


Solution

  • I updated azure.caching and azure.configuration via nuget, and then republished, and the error has now disappeared, no other code or configuration changes, so it looks like this was an incompatibility between DLL versions somewhere.