This is probably a silly question but can I call a non-idempotent with a retry policy?
The action is a SQL Write operation.
My understanding is that I am able to do it because the stored procedures I have are transactional so if they fail, the entire procedure will not be committed and can be retried again.
I've read some articles that mention to NOT call it through a retry policy anyway because sometimes the stored procedure successfully makes a change to the database but the consumer does not receive a successful response. But the retry policy I have is based off SQL exception and not status codes.
So I guess the question is, is there any other reason to not call it with a retry policy that I haven't thought about?
To be able to use retry the following criteria group should be met:
In other words
To reflect to your example
It might happen that the SQL server commits your transaction but unable to respond back to your application. In that case if you blindly retry it then you might end up having duplicates or even worse.
Most of the time I suggest to perform retry against databases whenever we know that the database acknowledges the transient error, like deadlock, resource limit has been reached, etc.
In case of Entity Framework Core there is a built-in retry support, here you can find the status codes against which the retry can be performed.