dixin / enterpriselibrary.transientfaulthandling.core Goto Github PK
View Code? Open in Web Editor NEWEnterprise Library - Transient Fault Handling Application Block for modern .NET with improvement.
License: MIT License
Enterprise Library - Transient Fault Handling Application Block for modern .NET with improvement.
License: MIT License
May be I'm wrong, but as far as I know a netstandard20 package can be used in a net48 project.
When using the library in a net48 project a Code Access Security exception is thrown:
I've attached a small console application: changing target framework from net5.0 to net48 you can see the problem.
and maybe look at differences between https://github.com/dotnet/efcore/blob/main/src/EFCore.SqlServer/Storage/Internal/SqlServerTransientExceptionDetector.cs
and https://github.com/Dixin/EnterpriseLibrary.TransientFaultHandling.Core/blob/master/Source/TransientFaultHandling.Data.Core/SqlDatabaseTransientErrorDetectionStrategy.cs
Setup ExponentialBackoff strategy with the following settings:
RetryCount = 100
MinBackoff = 1 second
MaxBackoff = 120 seconds
DeltaBackoff = 2 seconds
Use it in RetryPolicy and simulate retries (throw exception in ExecuteAsync).
Current Behaviour:
After 22 retries it starts to execute the action with delay 0.
Expected Behaviour
Action is executed with MaxBackoff delay (120 seconds).
Cause of the issue:
There is a bug in GetShouldRetry algorithm on this line:
int backoffMillisecond = (int)((Math.Pow(2.0, currentRetryCount) - 1.0) * random.Next((int)(this.deltaBackoff.TotalMilliseconds * 0.8), (int)(this.deltaBackoff.TotalMilliseconds * 1.2)));
There is a multiplication of 2 quite high integers and the result is greater than int.MaxValue. It results in overflow and negative result which is then set to 0 in RetryPolicy class:
if (zero.TotalMilliseconds < 0.0)
{
zero = TimeSpan.Zero;
}
Hi
When I publish my project with dotnet (Version 6.0.302) it throws error :
>dotnet.exe publish Reader.csproj --configuration Release --runtime win-x64 --output Reader/publish --self-contained true -property:Version=4.0.696
error CS0433: The type 'RetryPolicy' exists in both 'Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'TransientFaultHandling.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=dbe58f97a0872a64'
I even updated it to version 3.0 but still fails :
The type 'RetryPolicy' exists in both 'Microsoft.Practices.EnterpriseLibrary.Trans
ientFaultHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'TransientFaultHandling.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=
dbe58f97a0872a64'
Here is the cproj file :
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
<PackageReference Include="dapper" Version="2.0.35" />
<PackageReference Include="dapperextensions.netcore" Version="2.0.7" />
<PackageReference Include="EnterpriseLibrary.TransientFaultHandling.Core" Version="3.0.0" />
<PackageReference Include="FastMember" Version="1.5.0" />
<PackageReference Include="log4net" Version="2.0.14" />
<PackageReference Include="microsoft.aspnet.webapi.client" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="3.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Kubernetes.Tools.Targets" Version="1.1.0" />
<PackageReference Include="Nancy" Version="2.0.0" />
<PackageReference Include="Polly" Version="7.2.1" />
<PackageReference Include="Scrutor" Version="3.2.1" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
<PackageReference Include="TransientFaultHandling.Data" Version="3.0.0" />
I've noticed that you license this library under the MIT license, and state yourself as the copyright owner.
However, the upstream sources are licensed under the terms of the Apache License and list Microsoft as the copyright holder - see https://github.com/MicrosoftArchive/transient-fault-handling-application-block/blob/master/LICENSE.txt.
Are you sure that's correct? I'm asking because I'd like to redistribute this library with my application, but want to be sure the license & copyright information is correct.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.