Added condition to handle connection getting "out of sync". This can occur
when, for instance, you get a stray semicolon in a query. When a connection
gets in this state it is hosed and must be closed and reconnected.
So in this case we do a close/reconnect as well as log a error about it.