The code below contains a try/catch that I use a lot when developing batch jobs, especially multithreaded ones.
It deals with frequently occurring exceptions that, in some cases, can be easily solved by retrying:
- Deadlocks
- Update conflicts
- Duplicate key conflicts
Duplicate key conflicts are more rare than update conflicts, but I’ve seen them pop up under heavy load on InventDim records.