Maximum number of retries (6) exceeded while executing database operations with 'CosmosExecutionStrategy'

asp.net-core-2.2 azure-cosmosdb c# entity-framework-core graphql.net

Question

I am working on API development project using ASP.NET Core 2.2, GraphQL.NET , CosmosDB, Entity Framework Core (Microsoft.EntityFrameworkCore.Cosmos v2.2.4).

While testing the API method which pulls the data from AzureComosDB, sometime I get this error:

Microsoft.EntityFrameworkCore.Storage.RetryLimitExceededException: 'Maximum number of retries (6) exceeded while executing database operations with 'CosmosExecutionStrategy'. See inner exception for the most recent failure.'

I am not sure why this error is popping up intermittently.

Can anyone help me here by providing some guidance to fix this issue?

1
0
10/18/2019 4:17:46 PM

Accepted Answer

I would like to know more information about context file as the error says `

'Maximum number of retries (6) exceeded'

`. It might cause if you are trying to redeploy database on every request, So Considering you have already deployed database in cosmosdb it is recommended to remove Database.EnsureCreated() as will create performance issues.

Refer to this documentation for more information https://docs.microsoft.com/en-us/ef/core/providers/cosmos/?tabs=dotnet-core-cli

1
10/19/2019 9:07:37 AM

Popular Answer

First of all, have you checked the inner exception as stated in the error?

Microsoft.EntityFrameworkCore.Storage.RetryLimitExceededException: 'Maximum number of retries (6) exceeded while executing database operations with 'CosmosExecutionStrategy'. See inner exception for the most recent failure.'

it might give a clue as to why it is failing.

Now, this error is caused by the cosmos retry stategy. If an operation failes it will retry it to up to six times.

You can modify this strategy but the default can be found here. The fact that it is retried indicates it it an error that might be gone when retried. A good example is a glitch in the netwerk connection (like, when the wifi signal is bad). Another one could be the fact that the requests are exceeding the provisioned Request Unit limits.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow