MySQL会话状态提供程序在过期会话上崩溃
我有一个网站使用MySQL连接器6.7.4在IIS 7.5 ASP.NET 4中运行,我试图将它设置为将会话状态存储在我的数据库中。 它开始工作正常(我可以存储状态)。 但是,当我让浏览器长时间打开并尝试刷新页面时,出现以下错误:
重复条目'jouwlxjdufet2fyvf4cwefn2-1'为'PRIMARY'
说明: 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.
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.
异常详情:
MySql.Data.MySqlClient.MySqlException: Duplicate entry 'jouwlxjdufet2fyvf4cwefn2-1' for key 'PRIMARY'
源错误:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
堆栈跟踪:
[MySqlException (0x80004005): Duplicate entry 'jouwlxjdufet2fyvf4cwefn2-1' for key 'PRIMARY']
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +492
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) +450
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +136
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +1121
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +2648
MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +140
MySql.Web.SessionState.MySqlSessionStateStore.CreateUninitializedItem(HttpContext context, String id, Int32 timeout) +553
[ProviderException: An exception occurred. Please check the event log.]
MySql.Web.SessionState.MySqlSessionStateStore.HandleMySqlException(MySqlException e, String action) +281
MySql.Web.SessionState.MySqlSessionStateStore.CreateUninitializedItem(HttpContext context, String id, Int32 timeout) +709
System.Web.SessionState.SessionStateModule.GetSessionStateItem() +304
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1076
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +115
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1008
我的web.config包含以下内容
<system.web> <sessionState mode="Custom" cookieless="false" regenerateExpiredSessionId="false" customProvider="MySqlSessionStateProvider" timeout="20"> <providers> <add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore, MySql.Web, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="/skygdadmin" description="" connectionStringName="MySqlServer" writeExceptionsToEventLog="False" autogenerateschema="True" enableExpireCallback="True" /> </providers> </sessionState> ...
我可以在数据库中看到已经存在的条目:
表:my_aspnet_sessions
SessionId: 'jouwlxjdufet2fyvf4cwefn2'
ApplicationId: '1'
Created: '2013-08-22 08:29:34'
Expires: '2013-08-22 09:49:39'
LockDate: '2013-08-22 09:29:39'
LockId: '419'
Timeout: '20'
Locked: '0'
SessionItems: [lots of stuff]
Flats: '0'
此外,我可以看到my_aspnet_sessioncleanup表定期更新,表明会话清理正在运行(每10分钟)。
有没有人对从何处开始调试有任何想法? 谢谢大卫
修复!
我通过6.8.3版本的代码挖掘。
在SessionProvider.cs文件中:通过始终使用INSERT查询,代码假定数据库中不存在任何用于会话密钥的行 - 在会话创建时工作正常,但会话密钥引发异常被重新使用。
我已经在同一个文件中使用了一些类似的代码来修复它,并且我不再有异常。 修改的代码使用REPLACE查询而不是INSERT。
我附上了我的更新文件和一个关于MySQL站点上相应错误的补丁(我的基本版本是6.8.3)。 您可以下载6.8.3源代码并进行修补。 如果您自己编译AssemblyInfo.cs,则还必须注释掉AssemblyKeyName属性(对于强大的程序集名称)。
希望MySQL的人们能够将我的小小修补推向全面发行。
在这里看到我的笔记:
http://bugs.mysql.com/bug.php?id=70409
并且,解决方法直到MySql更新正式版本:
https://github.com/xavierjefferson/mysql-web-fixed
链接地址: http://www.djcxy.com/p/72705.html上一篇: MySQL Session state provider crashes on expired sessions