MXS-1323: Fix crash on attempted retry of read
When a backend is waiting for a response but no statement is stored for the session, the buffer where the stored statement is copied is not modified. This means that it needs to be initialized to a NULL value. Added a test that checks that the behavior works as expected even with persistent connections. A second test reproduces the crash by executing parallel SET commands while slaves are blocked. There is still a behavioral problem in readwritesplit. If a session command is being executed and it fails on a slave, an error is sent to the client. In this case it would not be necessary to close the session if the master is still alive.
This commit is contained in:
@ -1541,8 +1541,8 @@ static bool handle_error_new_connection(ROUTER_INSTANCE *inst,
|
||||
*/
|
||||
if (BREF_IS_WAITING_RESULT(bref))
|
||||
{
|
||||
GWBUF *stored;
|
||||
const SERVER *target;
|
||||
GWBUF *stored = NULL;
|
||||
const SERVER *target = NULL;
|
||||
|
||||
if (!session_take_stmt(backend_dcb->session, &stored, &target) ||
|
||||
target != bref->ref->server ||
|
||||
@ -1554,8 +1554,14 @@ static bool handle_error_new_connection(ROUTER_INSTANCE *inst,
|
||||
*/
|
||||
gwbuf_free(stored);
|
||||
|
||||
DCB *client_dcb = ses->client_dcb;
|
||||
client_dcb->func.write(client_dcb, gwbuf_clone(errmsg));
|
||||
if (!sescmd_cursor_is_active(&bref->bref_sescmd_cur))
|
||||
{
|
||||
/** The client expects a response from this exact backend.
|
||||
* We need to route an error to the client to let it know
|
||||
* that the query failed. */
|
||||
DCB *client_dcb = ses->client_dcb;
|
||||
client_dcb->func.write(client_dcb, gwbuf_clone(errmsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user