Avoid calling translate_exception with non-PGError exceptions.

translate_exception was changed and now expects the exception to respond to "result", here:  https://github.com/rails/rails/pull/6397
ActiveRecord::StatementInvalid, which is the exception sometimes caught and retried in the "connection retry" logic, does not respond to "result" and fails on the call to translate_exception.

Fixes replication test suite failure.

This fix can be squashed with the other "connection retry" commit (21e435403bad47a637c2c5d804f0748b66c8d091) on future upgrades.
Logger may be nil.

This fix can be squashed with the other "connection retry" commit (21e435403bad47a637c2c5d804f0748b66c8d091) on future upgrades.