Merge branch '2.3' into 2.4
This commit is contained in:
@ -918,6 +918,9 @@ static int gw_read_and_write(DCB* dcb)
|
||||
*/
|
||||
GWBUF_DATA(read_buffer)[3] = 0x3;
|
||||
proto->changing_user = false;
|
||||
|
||||
auto s = (MYSQL_session*)session->client_dcb->data;
|
||||
s->changing_user = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1718,7 +1718,15 @@ static int gw_client_hangup_event(DCB* dcb)
|
||||
errmsg += ": " + extra;
|
||||
}
|
||||
|
||||
modutil_send_mysql_err_packet(dcb, 0, 0, 1927, "08S01", errmsg.c_str());
|
||||
int seqno = 1;
|
||||
|
||||
if (dcb->data && ((MYSQL_session*)dcb->data)->changing_user)
|
||||
{
|
||||
// In case a COM_CHANGE_USER is in progress, we need to send the error with the seqno 3
|
||||
seqno = 3;
|
||||
}
|
||||
|
||||
modutil_send_mysql_err_packet(dcb, seqno, 0, 1927, "08S01", errmsg.c_str());
|
||||
}
|
||||
dcb_close(dcb);
|
||||
}
|
||||
@ -1921,6 +1929,10 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF
|
||||
|
||||
if (!proto->changing_user && proto->current_command == MXS_COM_CHANGE_USER)
|
||||
{
|
||||
// Track the COM_CHANGE_USER progress at the session level
|
||||
auto s = (MYSQL_session*)session->client_dcb->data;
|
||||
s->changing_user = true;
|
||||
|
||||
changed_user = true;
|
||||
send_auth_switch_request_packet(session->client_dcb);
|
||||
|
||||
|
@ -38,7 +38,7 @@ uint8_t null_client_sha1[MYSQL_SCRAMBLE_LEN] = "";
|
||||
MYSQL_session* mysql_session_alloc()
|
||||
{
|
||||
MYSQL_session* ses = (MYSQL_session*)MXS_CALLOC(1, sizeof(MYSQL_session));
|
||||
|
||||
ses->changing_user = false;
|
||||
return ses;
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,14 @@ bool RWBackend::write(GWBUF* buffer, response_type type)
|
||||
|
||||
if (mxs_mysql_is_ps_command(cmd))
|
||||
{
|
||||
// We need to completely separate the buffer this backend owns and the one that the caller owns to
|
||||
// prevent any modifications from affecting the one that was written through this backend. If the
|
||||
// buffer gets placed into the write queue of the DCB, subsequent modifications to the original buffer
|
||||
// would be propagated to the one this backend owns.
|
||||
GWBUF* tmp = gwbuf_deep_clone(buffer);
|
||||
gwbuf_free(buffer);
|
||||
buffer = tmp;
|
||||
|
||||
uint32_t id = mxs_mysql_extract_ps_id(buffer);
|
||||
BackendHandleMap::iterator it = m_ps_handles.find(id);
|
||||
|
||||
|
@ -235,12 +235,7 @@ bool RWSplitSession::route_single_stmt(GWBUF* querybuf)
|
||||
|
||||
RWBackend* target = nullptr;
|
||||
|
||||
if (command == MXS_COM_STMT_EXECUTE && stmt_id == 0)
|
||||
{
|
||||
// Unknown prepared statement ID
|
||||
succp = send_unknown_ps_error(extract_binary_ps_id(querybuf));
|
||||
}
|
||||
else if (TARGET_IS_ALL(route_target))
|
||||
if (TARGET_IS_ALL(route_target))
|
||||
{
|
||||
succp = handle_target_is_all(route_target, querybuf, command, qtype);
|
||||
}
|
||||
@ -282,6 +277,11 @@ bool RWSplitSession::route_single_stmt(GWBUF* querybuf)
|
||||
target = m_prev_target;
|
||||
succp = true;
|
||||
}
|
||||
else if (mxs_mysql_is_ps_command(command) && stmt_id == 0)
|
||||
{
|
||||
// Unknown prepared statement ID
|
||||
succp = send_unknown_ps_error(extract_binary_ps_id(querybuf));
|
||||
}
|
||||
else if (TARGET_IS_NAMED_SERVER(route_target) || TARGET_IS_RLAG_MAX(route_target))
|
||||
{
|
||||
if ((target = handle_hinted_target(querybuf, route_target)))
|
||||
|
@ -985,6 +985,18 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf,
|
||||
RWBackend* backend = get_backend_from_dcb(problem_dcb);
|
||||
mxb_assert(backend->in_use());
|
||||
|
||||
if (backend->reply_has_started())
|
||||
{
|
||||
MXS_ERROR("Server '%s' was lost in the middle of a resultset, cannot continue the session: %s",
|
||||
backend->name(), extract_error(errmsgbuf).c_str());
|
||||
|
||||
// This effectively causes an instant termination of the client connection and prevents any errors
|
||||
// from being sent to the client (MXS-2562).
|
||||
dcb_close(m_client);
|
||||
*succp = true;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case ERRACT_NEW_CONNECTION:
|
||||
|
Reference in New Issue
Block a user