add stale check, better db disconnection handling