Calling db:with-db inside a transaction was bad. Disallowed calling db:with-db with db and factored out few calls to take db. TCP connections seems stable. Fingers crossed.