I've been searching in vain for some kind of development pattern that will help me wrap a save to the database to allow a retry of the save if the database returns either a timeout or a deadlock error. Obviously I don't want to be locked into an endless loop, but I would like to be able to retry once or twice (configurable) when the database has a temporary issue.

Hi Joseph,

You can create a wrapper with an exception handler (for database error only) and in that flow, you can call again the Create action.

Don't forget to insert an if to test the number of times that you can have configurable by using a site property.

Maybe somthing like this, please note that I didn't tested. It's also possible that you need to parse the message to detect if it's a timeout or other kind of error.

Hmm. That looks possible, but I think it would require duplicating any code that follows the Save/Update/Create, etc. For example, on an insert, returning the new primary key to the original caller of the function. It would be nice, in the example above, on the False path of "Limit Try Passed" if you could draw the arrow back to the first "CreatePersonMovieRole". Or if we assume this action is called, "SavePersonMovieRole", if you could recursively call the action, which would require passing in a RetryCount parameter to prevent an endless loop.

Please note that this was a quick scenario that I created to better show you a possible way, so the return of the id is in fact missing.

Regarding the recursive call, yes you can also do that way to avoid duplicate logic.

I never did figure out how to call the server action from within itself, but I have also not yet simulated a database timeout or deadlock to trigger whatever action I needed to trigger. In this case, I simply needed to retry the create, and return the identifier, so I just did like your example, and added an Assign to get the identifier. I am also guessing that I will not be able to add a second Database Exception, so if that retry fails, I will need to catch it with All Exceptions. Still working at it.