asp.net mvc的蔚蓝"错误访问数据存储和QUOT!; [英] asp.net mvc azure "Error accessing the data store!"

查看:144
本文介绍了asp.net mvc的蔚蓝"错误访问数据存储和QUOT!;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用AspProviders code存储在我的表存储我的会话数据开始。

I've started using the AspProviders code to store my session data in my table storage.

我偶尔发现了以下错误:

I'm sporadically getting the following error:

<块引用>

说明:类型'System.Web.HttpException'引发的异常。 INNER_EXCEPTION:错误访问数据存储! INNER_EXCEPTION:处理此请求时出错。 INNER_EXCEPTION: ConditionNotMet 的条件使用指定的HTTP条件标题(s)是不符合。请求ID:0c4239cc-41fb-42c5-98c5-7e9cc22096af时间:2010-10-15T04:28:07.0726801Z
堆栈跟踪:
System.Web.SessionState.SessionStateModule.EndAcquireState(IAsyncResult的AR)
System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult的AR)INNER_EXCEPTION:
Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive(HttpContext背景下,串ID,在\\天青\\ AspProviders \\ TableStorageSessionStateProvider.cs对象lockId):484行
System.Web.SessionState.SessionStateModule.GetSessionStateItem()
System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(对象状态)INNER_EXCEPTION:
Microsoft.WindowsAzure.StorageClient.Tasks.Task 1.get_Result()
Microsoft.WindowsAzure.StorageClient.Tasks.Task
1.ExecuteAndWait()
Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry [T](Func`2 implement执行,RetryPolicy政策)
Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive(TableServiceContext SVC,SessionRow会议上,\\天青\\ AspProviders \\ TableStorageSessionStateProvider.cs对象lockId):603行
Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive(HttpContext背景下,串ID,在\\天青\\ AspProviders \\ TableStorageSessionStateProvider.cs对象lockId):行480 INNER_EXCEPTION:
System.Data.Services.Client.DataServiceContext.SaveResult.d__1e.MoveNext()

Description: Exception of type 'System.Web.HttpException' was thrown. INNER_EXCEPTION:Error accessing the data store! INNER_EXCEPTION:An error occurred while processing this request. INNER_EXCEPTION: ConditionNotMet The condition specified using HTTP conditional header(s) is not met. RequestId:0c4239cc-41fb-42c5-98c5-7e9cc22096af Time:2010-10-15T04:28:07.0726801Z StackTrace: System.Web.SessionState.SessionStateModule.EndAcquireState(IAsyncResult ar) System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) INNER_EXCEPTION: Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive(HttpContext context, String id, Object lockId) in \Azure\AspProviders\TableStorageSessionStateProvider.cs:line 484 System.Web.SessionState.SessionStateModule.GetSessionStateItem() System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(Object state) INNER_EXCEPTION: Microsoft.WindowsAzure.StorageClient.Tasks.Task1.get_Result() Microsoft.WindowsAzure.StorageClient.Tasks.Task1.ExecuteAndWait() Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry[T](Func`2 impl, RetryPolicy policy) Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive(TableServiceContext svc, SessionRow session, Object lockId) in \Azure\AspProviders\TableStorageSessionStateProvider.cs:line 603 Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.ReleaseItemExclusive(HttpContext context, String id, Object lockId) in \Azure\AspProviders\TableStorageSessionStateProvider.cs:line 480 INNER_EXCEPTION: System.Data.Services.Client.DataServiceContext.SaveResult.d__1e.MoveNext()

任何人碰到这个?我发现的唯一有用的信息是这样的,这我犹豫吗:

Anyone run into this? The only useful information I've found is this, which I'm hesitant to do:

<块引用>

如果你想绕过验证,可以打开TableStorageSessionStateProvider.cs,发现ReleaseItemExclusive,并修改code:

If you want to bypass the validation, you can open TableStorageSessionStateProvider.cs, find ReleaseItemExclusive, and modify the code from:

svc.UpdateObject(会话);

svc.UpdateObject(session);

svc.Detach(会话);结果
svc.AttachTo(会议,会议上,*);结果
svc.UpdateObject(会话);

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

这里

谢谢!

于是我决定改变这一点:

So I decided to change this:

<块引用>

svc.UpdateObject(会话);
svc.SaveChangesWithRetries();

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

这样:

<块引用>


{
    svc.UpdateObject(会话);

try { svc.UpdateObject(session);

svc.SaveChangesWithRetries();

}
抓住
{
    svc.Detach(会话);
    svc.AttachTo(会议,会议上,*);
    svc.UpdateObject(会话);

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

svc.SaveChangesWithRetries();

}

所以,我要看看它是如何工作...

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

推荐答案

我已经遇到了这个问题,以及经过一番调查,它似乎更多的时候,当你有多个实例发生,你试图在快速调用连续在同一个会话。 (例如,如果你有一个自动完成框,并在每个键preSS使Ajax调用)

I've encountered this problem as well and after some investigation it seems to happen more often when you have more than one instance and you try to make calls in rapid succession in the same session. (e.g. if you had an auto complete box and making ajax calls on each key press)

这是因为,当您尝试访问会话数据,首先在Web服务器中取出该届会议上的锁。当请求完成后,它释放锁。与表服务供应商,它通过在更新表的字段更新此锁定状态。我认为正在发生的是实例1加载会话行,然后实例2加载会话行,实例1节省下来更新的锁定状态,当实例2试图保存锁定状态,因为对象是不是在同一个状态下,它会得到一个错误当它加载它(的ETag不匹配任何更多)。

This occurs because when you try to access the session data, first of all the web server takes out a lock on that session. When the request is complete, it releases the lock. With the table service provider, it updates this lock status by updating a field in the table. What I think is happening is that Instance1 loads the session row, then Instance2 loads the session row, Instance1 saves down the updated lock status and when Instance2 attempts to save the lock status it gets an error because the object isn't in the same state as when it loaded it (the ETag doesn't match any more).

这就是为什么您认为会发生停止错误,因为通过指定在AttachTo*,当实例2试图保存锁将关闭的ETag检查(并在修复写所作的修改实例1)。

This is why the fix that you found will stop the error from occurring, because by specifying the "*" in the AttachTo, when Instance2 attempts to save the lock it will turn off ETag checking (and over write the changes made by Instance1).

在我们的情况,我们已经改变了供应商,使我们可以关闭某些路径会话(Ajax调用这是给我们我们的问题并不需要访问会话数据,也没有图片加载),这可能是你这取决于是什么原因造成您的问题的一个选择。

In our situation we have altered the provider so that we can turn off session for certain paths (the ajax call that was giving us our problems didn't need access to session data, neither did the loading of images) which may be an option for you depending on what is causing your problem.

不幸的是,TableStorageSessionStateProvider是样本项目的组成部分,因此并不是(据我所知,但我会高兴地另行告知)由微软官方支持。它确实有其他问题,喜欢的事实,一旦会话过期不清理它的会话数据,所以你最终将有很多垃圾的会话表和BLOB容器,你必须要清理一些其他方式。

Unfortunately the TableStorageSessionStateProvider is part of the sample projects and so isn't (as far as I'm aware, but I'll happily be told otherwise) officially supported by Microsoft. It does have other issues, like the fact that it doesn't clean up it's session data once a session expires, so you will end up with lots of junk in the session table and blob container that you'll have to clean up some other way.

这篇关于asp.net mvc的蔚蓝&QUOT;错误访问数据存储和QUOT!;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆