Skip to content

UseSQlServer->EnableRetryOnFailure with Atomic Operations | Unsupported execution strategy #1653

Closed
@kostas-kapasakis

Description

@kostas-kapasakis

SUMMARY

Hello ,

I am working in a jsonapi.net .net 8 api in which we use EFcore and SQL Server as our DB server.
We have already defined the application db context as below without the EnableRetryOnFailure configuration.

    `            .AddDbContext<ApplicationDbContext>((sp, options) =>
                 {
                     options.UseSqlServer(configuration.GetApplicationConnectionString(), o =>
                     {
                          o.UseCompatibilityLevel(120);
                     });
                 })
        
       `

We added atomic operations controller as described in the documentation and we are able to have the functionality we wanted.

Recently we encountered some transient errors during some api tests and thought to use the EnableRetryOnFailure configuration in order to remove some false negatives and as a consequence our services.AddDbContext was modified as below

    `            .AddDbContext<ApplicationDbContext>((sp, options) =>
                 {
                     options.UseSqlServer(configuration.GetApplicationConnectionString(), o =>
                     {
                          o.UseCompatibilityLevel(120);
                          o.EnableRetryOnFailure(
                            maxRetryCount: 5,
                            maxRetryDelay: TimeSpan.FromSeconds(30),
                            errorNumbersToAdd: null);
                          });
                 })
        
       `

Our API tests were stabilized and we did decrease the false negatives but our atomic operations are now fail with the following error.

"detail":"The configured execution strategy 'SqlServerRetryingExecutionStrategy' does not support user-initiated transactions.
Use the execution strategy returned by 'DbContext.Database.CreateExecutionStrategy()' to execute all the operations in the transaction as a retriable unit.",
"source":{"pointer":"/atomic:operations[0]"}}]}

Is there a way to tweak the execution strategy used by the atomic operations ?

VERSIONS USED

  • JsonApiDotNetCore version:5.6.0
  • ASP.NET Core version: 8
  • Entity Framework Core version: 8.0.1
  • Database provider: SQL Server

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions