Handle connection errors inside transactions

Given a master connection, and a connection error, the `handle_error`
method would `reset_master_connection` by setting the connection to
nil.

When the adapter connection is nillified, after rails reconnects
(automatically), rails gets confused and attempts to rollback
transactions, on the fresh connection that does not have any
transactions.

This commit lets rails know the connection needs to be reset by
calling the underlying adapter's `reset!` method. When we call
`reset!`, the master slave adapter is able to raise the original
exception message, wrapped in a ActiveRecord::MasterUnavailable
exception, allowing the caller to handle the down master.

The MasterUnavailable exception should only happen when the connection
is lost mid-transaction, or when the master is legitimately down. In
all other cases the mysql2 client will reconnect via `ping`.

The proper way to handle this exception is:

    begin
      transaction { ... }
    except ActiveRecord::MasterUnavailable => e
      if retryable?
        retry
      else
        log ...
      end
    end

If you must have a long running (idle) transaction make sure the mysql
@@wait_timeout is set to a reasonable value.

Change-Id: Iff3bcaec6f7344d74101440e6b7c424c26927cd3
Reviewed-on: https://gerrit.causes.com/23995
Reviewed-by: Lann Martin <lann@causes.com>
Reviewed-by: John Skopis <john.skopis@causes.com>
Tested-by: John Skopis <john.skopis@causes.com>