Implements retry strategy based on db error codes and wait interval.
Makes sure the connection to the database is alive before authorizing the retry of an action.