Asp.net mvc azure "Error accessing data warehouse!"

I started using AspProviders code to store session data in my table store.

I sporadically get the following error:

Description: The exception of type "System.Web.HttpException" is fixed. INNER_EXCEPTION: Error accessing data warehouse! INNER_EXCEPTION: An error occurred while processing this request. INNER_EXCEPTION: ConditionNotMet condition specified using conditional HTTP headers is not satisfied. RequestId: 0c4239cc-41fb-42c5-98c5-7e9cc22096af Time: 2010-10-15T04: 28: 07.0726801Z Stack Traces: System.Web.SessionState.SessionStateModule.EndAcquireState (IAsyncResultCentecAnpecultecnececnececpecnpecnpecpecnpecnpecnpecnpecpecnpecnpecnpecnpecnpecnpecnpecnpecnpecnpecnpecnpecnpecnpecpnec ar) INNER_EXCEPTION: Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive (HttpContext context, string identifier, Object lockId) in \ Azure \ AspProviders \ TableStorageSessionStateProvider.cs: line 484 System.Web.SessionState.SessionStateModule.GetSessionStateItem () System. Web.SessionState.SessionStateModule.PollLockedSessionCallback (state of the object) INNER_EXCEPTION: Microsoft.WindowsAzure.StorageClient.Tasks.Task 1.get_Result() Microsoft.WindowsAzure.StorageClient.Tasks.Task 1.ExecuteAndWait () Microsoft.WindowsWecHplTel.TelTet.PlutePlaza.TelperItel.TeLet.TelTePlute.Plate.Plate.zelTelTeLet.TelTePlEtTerIplEptElEnterPlane [T] (Func`2 impl, Ret policy ryPolicy) Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive (TableServiceContext svc, SessionRow session, Object lockId) in \ Azure \ AspProviders \ TableStorageSessionStateProvider.cs: line 603 Microsoft.SingSpectTerviceProvider.cervicePerviceProvider.cshtpentervicePeriderovcer.htperviceprovider.cshtpenterprovider.cshtpenterprovider.c. String id, Object lockId) in \ Azure \ AspProviders \ TableStorageSessionStateProvider.cs: line 480 INNER_EXCEPTION: System.Data.Services.Client.DataServiceContext.SaveResult.d__1e.MoveNext ()

Does anyone come across this? The only useful information I found is what I hesitate to do:

If you want to bypass the check, you can open TableStorageSessionStateProvider.cs, find ReleaseItemExclusive and change the code:

svc.UpdateObject (session);

in

svc.Detach (session);
svc.AttachTo ("Sessions", session, "*");
svc.UpdateObject (session);

from here

Thanks!

So, I decided to change this:

svc.UpdateObject (session); svc.SaveChangesWithRetries ();

:

try {svc.UpdateObject (session);

 svc.SaveChangesWithRetries(); 

} catch {svc.Detach (session); svc.AttachTo ("Sessions", session, "*"); svc.UpdateObject (session);

 svc.SaveChangesWithRetries(); 

}

So, I'll see how it works ...

+4
source share
1 answer

I also ran into this problem, and after some investigation, this happens more often when you have more than one instance and you are trying to quickly make the same call. (for example, if you have autocomplete and ajax call each time you press a key)

This is because when you try to access session data, the web server first blocks the session. When the request is complete, it will release the lock. With the table service provider, it updates this lock status by updating the field in the table. I believe that instance 1 loads the session line and Instance2 loads the session line, instance 1 saves the updated lock status and when instance2 tries to keep the lock status, it gets an error because the object is not in the same state as when it was loaded (ETag is no longer does not match).

This is why the fix you found will stop the error, because by specifying "*" in AttachTo, when Instance2 tries to save the lock, it will disable ETag checking (and write down the changes made by Instance1).

In our situation, we changed the provider so that we could disconnect the session for certain paths (the ajax call, which gave us our problems, did not need access to the session data, as well as downloading images), which may be an option for you depending on what causes your problem.

Unfortunately, TableStorageSessionStateProvider is part of standard projects, and this is not the case (as far as I know, but I will gladly talk about it) officially supported by Microsoft. It has other problems, for example, the fact that it does not clear the session data after the session expires, so you will have many unwanted messages in the session table and blob container that you will have to clear the path.

+9
source

All Articles