implement smart retry handler

Adds a "smart" retry handler (using the so far unused ProcessingAlgo) and adds a few extra DAOs used by the new retry handler. This will need some extensive tests before it can be merged. Any testing also requires the workqueue modification in #4753.