2012-03-03 4 views
0

У меня есть веб-сервис WCF с настраиваемым httpModule, который я использую для аутентификации UserName/Password для MysqlMembership.MysqlMembership Membership.ValidateUser Проблема с блокировкой при загрузке

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 

Любые идеи?

Спасибо, AFrieze

ответ

0

Пользователь Validate блокирует строку для того, чтобы увеличить недействительных попыток ввода пароля, если пароль оказывается недействительным:

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

С вами используют одного и того же пользователя для всех запросов, вы можете получить тупик.

+0

Фактическая ошибка была в тупике на lastActivityDate, но такой же эффект. – AFrieze