gpt4 book ai didi

.net - MysqlMembership Membership.ValidateUser 负载下出现死锁问题

转载 作者:行者123 更新时间:2023-11-29 14:33:35 28 4
gpt4 key购买 nike

我有一个带有自定义 httpModule 的 WCF Web 服务,我用它对 MysqlMembership 进行用户名/密码身份验证。

public void Init(HttpApplication application)
{
application.AuthenticateRequest += new EventHandler(this.OnAuthenticateRequest);
application.EndRequest += new EventHandler(this.OnEndRequest);
}

public void OnAuthenticateRequest(object source, EventArgs eventArgs)
{
...
...

if (Membership.ValidateUser(username, password))
{

当我开始对服务进行负载测试时,我遇到了一个令人困惑的问题。请求随机失败 Membership.ValidateUser 调用。我对负载测试器中的每个线程使用相同的用户名/登录名。这是错误:

  [MySqlException (0x80004005): Deadlock found when trying to get lock; try restarting transaction]
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +506
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId) +450
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +131
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +1216
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +2191
MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +27
MySql.Web.Security.MySQLMembershipProvider.ValidateUser(String username, String password) +1092

[ProviderException: An exception occurred. Please check the Event Log.]
MySql.Web.Security.MySQLMembershipProvider.ValidateUser(String username, String password) +1481
MyApplication.UserAuthenticator.UserNameAuthenticator.OnAuthenticateRequest(Object source, EventArgs eventArgs) in C:\Develop\MyProject\MyProject.UserAuthenticator\UserNameAuthenticator.cs:123
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270

有什么想法吗?

谢谢,弗里兹

最佳答案

如果密码无效,验证用户会锁定该行,以便增加无效密码尝试次数:

If an incorrect password is supplied to the ValidateUser method, the internal counter that tracks invalid password attempts is incremented by one. This can result in the user being locked out and unable to log on until the lock status is cleared by a call to the UnlockUser method. If the correct password is supplied and the user is not currently locked out, then the internal counters that track invalid password and password-answer attempts are reset to zero. For more information, see the MaxInvalidPasswordAttempts and PasswordAttemptWindow properties.

http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider.validateuser.aspx

由于您对所有请求使用同一用户,因此可能会出现死锁。

关于.net - MysqlMembership Membership.ValidateUser 负载下出现死锁问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9550711/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com