The basic principle is that you repeat any transaction that does not work for a reason that may be more invalid. Therefore, if the transaction failed due to a deadlock or poor connection to the database server, you should retry several times with a sleeping sleep between each attempt. It depends on how well your transaction is defined .
Depending on your logic, you can implement a retry at the page request level.
- It depends on how safe it is to repeat the work that the page request does, or to fully advance the page request within the database transaction.
- Also think about any state of memory that you store on the server.
- The HttpHander added to the page processing pipeline should be able to do this for all pages.
I donโt think your code has โmagic you can spindleโ to figure it out if you do not have clear transactions.
If you are not using any transaction, you can try to write all your sql so that it can be safely run as many times as you like, and then just have a custom subclass of the command object, which is executed if necessary.
source share