Merge branch '2.3' into develop

This commit is contained in:
Markus Mäkelä
2019-01-07 10:52:07 +02:00
67 changed files with 777 additions and 469 deletions

View File

@ -214,7 +214,8 @@ static char* get_users_query(const SERVER::Version& version, bool include_root,
switch (category)
{
case SERVER_ROLES:
rval = version.total >= 100202 ? get_mariadb_102_users_query(include_root) :
// Require 10.2.15 due to MDEV-15840 and MDEV-15556
rval = version.total >= 100215 ? get_mariadb_102_users_query(include_root) :
get_mariadb_101_users_query(include_root);
break;

View File

@ -285,9 +285,9 @@ static bool is_localhost_address(struct sockaddr_storage* addr)
*/
static int mysql_auth_authenticate(DCB* dcb)
{
int auth_ret = ssl_authenticate_check_status(dcb);
int auth_ret = MXS_AUTH_SSL_COMPLETE;
MYSQL_session* client_data = (MYSQL_session*)dcb->data;
if (auth_ret == MXS_AUTH_SSL_COMPLETE && *client_data->user)
if (*client_data->user)
{
MXS_DEBUG("Receiving connection from '%s' to database '%s'.",
client_data->user,

View File

@ -332,9 +332,9 @@ Buffer PamClientSession::create_auth_change_packet() const
int PamClientSession::authenticate(DCB* dcb)
{
int rval = ssl_authenticate_check_status(dcb);
int rval = MXS_AUTH_SSL_COMPLETE;
MYSQL_session* ses = static_cast<MYSQL_session*>(dcb->data);
if (rval == MXS_AUTH_SSL_COMPLETE && *ses->user)
if (*ses->user)
{
rval = MXS_AUTH_FAILED;
if (m_state == PAM_AUTH_INIT)

View File

@ -205,9 +205,9 @@ void GaleraMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
info.local_state = atoi(row[1]);
}
if (strcmp(row[0], "wsrep_cluster_state_uuid") == 0)
if (strcmp(row[0], "wsrep_cluster_state_uuid") == 0 && row[1] && *row[1])
{
info.cluster_uuid = row[1] && *row[1] ? MXS_STRDUP(row[1]) : NULL;
info.cluster_uuid = row[1];
}
}

View File

@ -222,10 +222,9 @@ std::string get_version_string(SERVICE* service)
}
// Older applications don't understand versions other than 5 and cause strange problems
const char prefix[] = "5.5.5-";
if (strncmp(rval.c_str(), prefix, sizeof(prefix) - 1) != 0)
if (rval[0] != '5')
{
const char prefix[] = "5.5.5-";
rval = prefix + rval;
}
@ -732,7 +731,13 @@ static int gw_read_do_authentication(DCB* dcb, GWBUF* read_buffer, int nbytes_re
int auth_val = MXS_AUTH_FAILED;
if (dcb->authfunc.extract(dcb, read_buffer))
{
auth_val = dcb->authfunc.authenticate(dcb);
auth_val = ssl_authenticate_check_status(dcb);
if (auth_val == MXS_AUTH_SSL_COMPLETE)
{
// TLS connection phase complete
auth_val = dcb->authfunc.authenticate(dcb);
}
}
else
{

View File

@ -106,9 +106,9 @@ const Stats& RWSplit::stats() const
return m_stats;
}
ServerStats& RWSplit::server_stats(SERVER* server)
SrvStatMap& RWSplit::local_server_stats()
{
return (*m_server_stats)[server];
return *m_server_stats;
}
maxscale::SrvStatMap RWSplit::all_server_stats() const

View File

@ -261,7 +261,7 @@ public:
const Config& config() const;
Stats& stats();
const Stats& stats() const;
ServerStats& server_stats(SERVER* server);
SrvStatMap& local_server_stats();
SrvStatMap all_server_stats() const;
int max_slave_count() const;

View File

@ -41,23 +41,25 @@ void RWSplitSession::handle_connection_keepalive(RWBackend* target)
mxb_assert(target);
MXB_AT_DEBUG(int nserv = 0);
/** Each heartbeat is 1/10th of a second */
int keepalive = m_config.connection_keepalive * 10;
int64_t keepalive = m_config.connection_keepalive * 10;
int64_t now = mxs_clock();
for (auto it = m_raw_backends.begin(); it != m_raw_backends.end(); it++)
if (now - m_last_keepalive_check > keepalive)
{
RWBackend* backend = *it;
if (backend->in_use() && backend != target && !backend->is_waiting_result())
for (const auto& backend : m_raw_backends)
{
MXB_AT_DEBUG(nserv++);
int diff = mxs_clock() - backend->dcb()->last_read;
if (diff > keepalive)
if (backend->in_use() && backend != target && !backend->is_waiting_result())
{
MXS_INFO("Pinging %s, idle for %ld seconds",
backend->name(),
MXS_CLOCK_TO_SEC(diff));
modutil_ignorable_ping(backend->dcb());
MXB_AT_DEBUG(nserv++);
int64_t diff = now - backend->dcb()->last_read;
if (diff > keepalive)
{
MXS_INFO("Pinging %s, idle for %ld seconds",
backend->name(),
MXS_CLOCK_TO_SEC(diff));
modutil_ignorable_ping(backend->dcb());
}
}
}
}
@ -473,8 +475,8 @@ bool RWSplitSession::route_session_write(GWBUF* querybuf, uint8_t command, uint3
{
nsucc += 1;
mxb::atomic::add(&backend->server()->stats.packets, 1, mxb::atomic::RELAXED);
m_router->server_stats(backend->server()).total++;
m_router->server_stats(backend->server()).read++;
m_server_stats[backend->server()].total++;
m_server_stats[backend->server()].read++;
if (expecting_response)
{
@ -849,7 +851,7 @@ RWBackend* RWSplitSession::handle_slave_is_target(uint8_t cmd, uint32_t stmt_id)
if (target)
{
mxb::atomic::add(&m_router->stats().n_slave, 1, mxb::atomic::RELAXED);
m_router->server_stats(target->server()).read++;
m_server_stats[target->server()].read++;
mxb_assert(target->in_use() || target->can_connect());
}
else
@ -986,7 +988,7 @@ bool RWSplitSession::handle_master_is_target(RWBackend** dest)
if (target && target == m_current_master)
{
mxb::atomic::add(&m_router->stats().n_master, 1, mxb::atomic::RELAXED);
m_router->server_stats(target->server()).write++;
m_server_stats[target->server()].write++;
}
else
{
@ -1166,7 +1168,7 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, RWBackend* target, bool
mxb::atomic::add(&m_router->stats().n_queries, 1, mxb::atomic::RELAXED);
mxb::atomic::add(&target->server()->stats.packets, 1, mxb::atomic::RELAXED);
m_router->server_stats(target->server()).total++;
m_server_stats[target->server()].total++;
if (!m_qc.large_query() && response == mxs::Backend::EXPECT_RESPONSE)
{

View File

@ -17,6 +17,7 @@
#include <maxscale/modutil.hh>
#include <maxscale/poll.hh>
#include <maxscale/clock.h>
using namespace maxscale;
@ -29,11 +30,11 @@ RWSplitSession::RWSplitSession(RWSplit* instance,
, m_raw_backends(sptr_vec_to_ptr_vec(m_backends))
, m_current_master(master)
, m_config(instance->config())
, m_last_keepalive_check(mxs_clock())
, m_nbackends(instance->service()->n_dbref)
, m_client(session->client_dcb)
, m_sescmd_count(1)
, // Needs to be a positive number to work
m_expected_responses(0)
, m_expected_responses(0)
, m_query_queue(NULL)
, m_router(instance)
, m_sent_sescmd(0)
@ -45,6 +46,7 @@ RWSplitSession::RWSplitSession(RWSplit* instance,
, m_retry_duration(0)
, m_is_replay_active(false)
, m_can_replay_trx(true)
, m_server_stats(instance->local_server_stats())
{
if (m_config.rw_max_slave_conn_percent)
{
@ -86,7 +88,7 @@ RWSplitSession* RWSplitSession::create(RWSplit* router, MXS_SESSION* session)
for (auto& b : backends)
{
router->server_stats(b->server()).start_session();
rses->m_server_stats[b->server()].start_session();
}
}
}
@ -124,9 +126,9 @@ void RWSplitSession::close()
}
backend->response_stat().reset();
m_router->server_stats(backend->server()).end_session(backend->session_timer().split(),
backend->select_timer().total(),
backend->num_selects());
m_server_stats[backend->server()].end_session(backend->session_timer().split(),
backend->select_timer().total(),
backend->num_selects());
}
}

View File

@ -274,6 +274,7 @@ private:
mxs::RWBackend* m_target_node; /**< The currently locked target node */
mxs::RWBackend* m_prev_target; /**< The previous target where a query was sent */
Config m_config; /**< Configuration for this session */
int m_last_keepalive_check; /**< When the last ping was done */
int m_nbackends; /**< Number of backend servers (obsolete) */
DCB* m_client; /**< The client DCB */
uint64_t m_sescmd_count; /**< Number of executed session commands */
@ -305,6 +306,10 @@ private:
mxs::Buffer m_orig_stmt; /**< The backup of the statement that was interrupted */
otrx_state m_otrx_state = OTRX_INACTIVE; /**< Optimistic trx state*/
SrvStatMap& m_server_stats; /**< The server stats local to this thread, cached in the session object.
* This avoids the lookup involved in getting the worker-local value from
* the worker's container.*/
};
/**