Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

System.OperationCanceledException at Microsoft.Extensions.Caching.Redis.RedisCache+<RefreshAsync>d__25.MoveNext #189

Closed
Tratcher opened this issue Aug 29, 2017 · 4 comments
Assignees

Comments

@Tratcher
Copy link
Member

From @TrplM on August 29, 2017 6:27

Hi

I am getting a lot of these errors reported in azure app insights. Any idea on what could be causing this and how to track down what is throwing the exception.

This is the stack trace logged in app insights

System.OperationCanceledException:
   at System.Threading.CancellationToken.ThrowOperationCanceledException (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Threading.CancellationToken.ThrowIfCancellationRequested (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Extensions.Caching.Redis.RedisCache+<RefreshAsync>d__25.MoveNext (Microsoft.Extensions.Caching.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Extensions.Caching.Redis.RedisCache+<GetAndRefreshAsync>d__20.MoveNext (Microsoft.Extensions.Caching.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Extensions.Caching.Redis.RedisCache+<RefreshAsync>d__16.MoveNext (Microsoft.Extensions.Caching.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.Session.DistributedSession+<CommitAsync>d__32.MoveNext (Microsoft.AspNetCore.Session, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.Session.SessionMiddleware+<Invoke>d__9.MoveNext (Microsoft.AspNetCore.Session, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.0.0" />
    ...
  </ItemGroup>
</Project>
.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Copied from original issue: aspnet/Caching#351

@Tratcher
Copy link
Member Author

It's coming from here:

try
{
await feature.Session.CommitAsync(context.RequestAborted);
}
catch (Exception ex)
{
_logger.ErrorClosingTheSession(ex);
}

What's new in 2.0 is that IDistributedCache supports CancellationTokens, so Session passes the RequestAborted token. The effect of this is that if the client disconnects before the response is finished then their session changes are not persisted and you get this error logged.

We should consider special casing this exception type and downgrading the log level.

@amirjalali1
Copy link

@Tratcher
will it be available in version 2.0.1. and is there any release date for version 2.0.1 ?
is it really an error? and is there any solution for this issue?
i set log level to warning and above.
currently my log db has get so cluttered because of this error.

@Tratcher
Copy link
Member Author

We haven't made any changes yet and have not decided if this should be included in any patches.

@muratg We've gotten several hits on this. Adjusting the logging may be appropriate for a patch.

@muratg muratg added this to the 2.0.3 milestone Sep 26, 2017
@muratg
Copy link

muratg commented Sep 26, 2017

@Tratcher agreed. @Eilon, patch candidate in 2.0. Idea is the to

  1. Lower the log level, to Info
  2. Change the message. Remove the stack trace and add a line mentioning client disconnect.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants