Sleep at least 1 s before reconnecting regardless of other factors.
Handle database connection errors more gracefully.