Merge branch '2.3' into 2.4

This commit is contained in:
Markus Mäkelä 2019-12-17 14:04:47 +02:00
commit f39ed6803e
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
4 changed files with 32 additions and 5 deletions

View File

@ -36,7 +36,7 @@ Table of Contents
* [verify_master_failure and master_failure_timeout](#verify_master_failure-and-master_failure_timeout)
* [servers_no_promotion](#servers_no_promotion)
* [promotion_sql_file and demotion_sql_file](#promotion_sql_file-and-demotion_sql_file)
* [handle_server_events](#handle_server_events)
* [handle_events](#handle_events)
* [Troubleshooting](#troubleshooting)
* [Failover/switchover fails](#failoverswitchover-fails)
* [Slave detection shows external masters](#slave-detection-shows-external-masters)
@ -331,7 +331,7 @@ being demoted or promoted by cluster manipulation commands. See the sections on
`promotion_sql_file` and `demotion_sql_file` for more information.
The monitor can manipulate scheduled server events when promoting or demoting a
server. See the section on `handle_server_events` for more information.
server. See the section on `handle_events` for more information.
All cluster operations can be activated manually through MaxAdmin/MaxCtrl. See
section [Manual activation](#manual-activation) for more details.
@ -818,7 +818,7 @@ slave threads are stopped, breaking replication.
promotion_sql_file=/home/root/scripts/promotion.sql
demotion_sql_file=/home/root/scripts/demotion.sql
```
#### `handle_server_events`
#### `handle_events`
This setting is on by default. If enabled, the monitor continuously queries the
servers for enabled scheduled events and uses this information when performing

View File

@ -357,6 +357,16 @@ public:
*/
void set_close_reason(const std::string& reason);
/**
* Get latest close reason
*
* @return A human-readable reason why the connection was closed
*/
const std::string& close_reason() const
{
return m_close_reason;
}
private:
/**
* Internal state of the backend

View File

@ -197,6 +197,7 @@ bool Backend::connect(MXS_SESSION* session, SessionCommandList* sescmd)
m_closed_at = 0;
m_opened_at = time(NULL);
m_state = IN_USE;
m_close_reason.clear();
mxb::atomic::add(&m_backend->connections, 1, mxb::atomic::RELAXED);
rval = true;
m_history_size = 0;

View File

@ -678,6 +678,20 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
if (error.is_unexpected_error())
{
// The connection was killed, we can safely ignore it. When the TCP connection is
// closed, the router's error handling will sort it out.
if (error.code() == ER_CONNECTION_KILLED)
{
backend->set_close_reason("Connection was killed");
}
else
{
mxb_assert(error.code() == ER_SERVER_SHUTDOWN
|| error.code() == ER_NORMAL_SHUTDOWN
|| error.code() == ER_SHUTDOWN_COMPLETE);
backend->set_close_reason(std::string("Server '") + backend->name() + "' is shutting down");
}
// The server sent an error that we didn't expect: treat it as if the connection was closed. The
// client shouldn't see this error as we can replace the closed connection.
@ -1125,9 +1139,11 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf,
{
int64_t idle = mxs_clock() - backend->dcb()->last_read;
MXS_ERROR("Lost connection to the master server '%s', closing session.%s "
"Connection has been idle for %.1f seconds. Error caused by: %s",
"Connection has been idle for %.1f seconds. Error caused by: %s. "
"Last close reason: %s",
backend->name(), errmsg.c_str(), (float)idle / 10.f,
extract_error(errmsgbuf).c_str());
extract_error(errmsgbuf).c_str(),
backend->close_reason().empty() ? "<none>" : backend->close_reason().c_str());
}
// Decrement the expected response count only if we know we can continue the sesssion.