Erro estranho no SQL Server do aplicativo ASP.NET

1

Eu postei essa pergunta no estouro de pilha, mas sem sucesso. Ficando desesperado aqui.

Portanto, temos um erro extremamente aleatório (pelo qual quero dizer, parece não haver nenhum padrão de uso que preceda o erro) em nosso aplicativo C # ASP.NET MVC5, que ocorre em nosso ambiente de produção.

O erro parece ocorrer apenas algumas vezes depois que um usuário efetua login e o sistema inteiro falha e fica inacessível a todos os usuários até que entramos manualmente no IIS8 e reinicie o servidor da web. Estamos executando o SQL Server Express 2012 SP2 em um ambiente Windows Server 2012 com o IIS.

A mensagem de erro é a seguinte:

IndexOutOfRangeException/Account/Login
Index was outside the bounds of the array.

O rastreamento de pilha é o seguinte:

IndexOutOfRangeException·Index was outside the bounds of the array.
Raw
:0System.Data.SqlClient.SqlDataReader.CheckHeaderIsReady(Int32 columnIndex, Boolean permitAsync, String methodName) 
 :0System.Data.SqlClient.SqlDataReader.IsDBNull(Int32 i)    
 :0System.Data.Entity.Core.Common.Internal.Materialization.Shaper+ErrorHandlingValueReader'1.GetValue(DbDataReader reader, Int32 ordinal)   
 :0lambda_method(Closure , Shaper ) 
 :0System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly(Func'2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)  
 :0lambda_method(Closure , Shaper ) 
 :0System.Data.Entity.Core.Common.Internal.Materialization.Coordinator'1.ReadNextElement(Shaper shaper) 
 :0System.Data.Entity.Core.Common.Internal.Materialization.Shaper'1+SimpleEnumerator+<MoveNextAsync>d__4.MoveNext() 
 :0System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)    
 :0System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   
 :0System.Data.Entity.Internal.LazyAsyncEnumerator'1+<FirstMoveNextAsync>d__0.MoveNext()    
 :0System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)    
 :0System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   
 :0System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions+<FirstOrDefaultAsync>d__25'1.MoveNext()   
 :0System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)    
 :0System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   
 :0Microsoft.AspNet.Identity.TaskExtensions+CultureAwaiter'1.GetResult()    
 :0Microsoft.AspNet.Identity.EntityFramework.UserStore'6+<GetUserAggregateAsync>d__6c.MoveNext()    
 :0System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)    
 :0System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   
 :0Microsoft.AspNet.Identity.TaskExtensions+CultureAwaiter'1.GetResult()    
 :0Microsoft.AspNet.Identity.UserManager'2+<FindAsync>d__12.MoveNext()  
 :0System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)    
 :0System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   
 :0Saleboat.Controllers.AccountController+<Login>d__9.MoveNext()    
 :0System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)    
 :0System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   
 :0System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)  
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult)   
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)    
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()    
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()    
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()    
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) 
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21+<>c__DisplayClass2b.<BeginInvokeAction>b__1c() 
 :0System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

Este erro ocorre apenas em nosso servidor / banco de dados ativo e não pode ser intencionalmente reproduzido, nós praticamente temos que esperar que isso aconteça e revisar a exceção capturada pelo Bugsnag.

EDITAR

Aqui está o código executado no login:

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            var user = await UserManager.FindAsync(model.UserName, model.Password);
            if (user != null)
            {
                var userId = UserManager.FindByName(model.UserName).Id;
                int companyId = db.Users.Find(userId).CompanyId;
                await SignInAsync(user, model.RememberMe);
                return RedirectToLocal(returnUrl);
            }
            else
            {
                ModelState.AddModelError("", "Invalid username or password.");
            }
        }
        return View(model);
    }
    
por barnacle.m 15.03.2016 / 18:04

0 respostas