class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

def reconnect!

Close then reopen the connection.
def reconnect!
  @lock.synchronize do
    super
    @connection.reset
    configure_connection
    reload_type_map
  rescue PG::ConnectionBad
    connect
  end
end