Improve the handling of broken or otherwise lost database connections.

Change-Id: I532a516d50a2c55ddf562268be6465e59355fb69