-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry operation for resiliency strategy is not working #596
Comments
Hello @RaHorusFreak , The So, it currently does not affect PostgreSQL and indeed confirms your observation about it. We could change it, but even then, I'm not sure it will 100% cover your scenario as our library just re-try the same operation. It doesn't re-open currently. Try to re-open the connection (which should still be open, I believe, since you are inside a transaction)... We will just re-try the same operation in case of a transient error (or error code you choose) If that's enough for you, then we can look at adding the support to PostgreSQL as well. Best Regards, Jon |
Hello @JonathanMagnan, thank you very much for your time. We managed to change the logic of the method and we are handling right now the rollback process because of dotnet/efcore#34214. So if the bulk operations are able to retry the same instruction within a transient failure escenario (no transaction involved) for PostgreSQL, it will be great for us. context.Database.OpenConnection(); at the beginning of each batch, paying attention to the IsTransient property of the DbException that occurred. |
Thank you for the additional information, I cannot promise you anything yet, but we will surely look into it. Best Regards, Jon |
Description
I have a method for executing several operations against a PostgreSQL database from an API in .Net 8. The database context has configurated the following resiliency strategy:
And also, we configured all EntityFramework-Extensions options to be executed identically:
The next code shows an extract of the method I’m using for deleting a very high amount of data (among other operations):
And the problem is that, in the event of connection failures (random or forced to test), exceptions are always generated, and operations are never retried.
Exception
System.InvalidOperationException: Connection is not open\r\n at Npgsql.ThrowHelper.ThrowInvalidOperationException(String message)\r\n at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)\r\n at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)\r\n at Npgsql.NpgsqlCommand.ExecuteNonQuery()\r\n at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.RollbackToSavepoint(String name)\r\n at SEAMIND.Datamodels.Logic.Model.IndicatorDatumLogic.Finalization(IDbContextTransaction transaction, Exception exc, List
1 logs, Action
1 replicator, CancellationToken& ct)\r\n at SEAMIND.Datamodels.Logic.Model.IndicatorDatumLogic.<>c__DisplayClass13_0.<<ProcessData_INE>b__2>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at SEAMIND.Datamodels.Logic.Model.IndicatorDatumLogic.ProcessData_INE(Int32 userId, Int32 indicatorId, DateTime date, IndicatorUploadStatus iuStatus, Int32 iuTypeId, IEnumerable1 rows, DDomainEntityCodeContainer dimDom, Boolean isEn, PreserverDictionary
2 map, IndicatorImportData importData, Action1 setTotal, Action
1 setPart, Action1 setSkip, Action
1 replicator, CancellationToken ct)Placing breakpoints and shutting down the connection to the database server evidences that there's no retry function being executed:
I’ve tried with isolated EF queries and the retry policy is working as expected. I putted ne next code within an infinity loop, and when I closed the database connection, the process starts retrying itself:
Thank you in advance for any help you can provide to me.
The text was updated successfully, but these errors were encountered: