Catching db errors and restarting it better