Giter VIP home page Giter VIP logo

enterpriselibrary.transientfaulthandling.core's People

Contributors

dixin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

enterpriselibrary.transientfaulthandling.core's Issues

The package can't be used in a net48 project

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:

  • Type: System.TypeAccessException
  • Message: Attempt by security transparent method 'Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.SqlDatabaseTransientErrorDetectionStrategy.IsTransient(System.Exception)' to access security critical type 'Microsoft.Data.SqlClient.SqlException' failed.

I've attached a small console application: changing target framework from net5.0 to net48 you can see the problem.

ReproCode.zip

Zero delay in ExponentialBackoff strategy after few retries

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;
}

The type 'RetryPolicy' exists in both 'Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling'

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" />

License & Copyright

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.