Allocate blr heartbeat buffer on correct worker

The buffer was allocated on one worker and written on another.
This commit is contained in:
Markus Mäkelä
2019-05-09 10:13:43 +03:00
parent 788dc429f8
commit 59f2145c00

View File

@ -243,7 +243,7 @@ static int blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE* router,
int len, int len,
uint8_t seqno); uint8_t seqno);
static bool blr_send_slave_heartbeat(void* inst); static bool blr_send_slave_heartbeat(void* inst);
static int blr_slave_send_heartbeat(ROUTER_INSTANCE* router, static void blr_slave_send_heartbeat(ROUTER_INSTANCE* router,
ROUTER_SLAVE* slave); ROUTER_SLAVE* slave);
static int blr_set_master_ssl(ROUTER_INSTANCE* router, static int blr_set_master_ssl(ROUTER_INSTANCE* router,
const ChangeMasterConfig& config, const ChangeMasterConfig& config,
@ -6204,13 +6204,11 @@ static bool blr_send_slave_heartbeat(void* inst)
sptr->heartbeat, sptr->heartbeat,
(unsigned long)sptr->lastReply); (unsigned long)sptr->lastReply);
if (blr_slave_send_heartbeat(router, sptr)) blr_slave_send_heartbeat(router, sptr);
{ /* Set last event */
/* Set last event */ sptr->lastEventReceived = HEARTBEAT_EVENT;
sptr->lastEventReceived = HEARTBEAT_EVENT; /* Set last time */
/* Set last time */ sptr->lastReply = t_now;
sptr->lastReply = t_now;
}
} }
sptr = sptr->next; sptr = sptr->next;
@ -6228,7 +6226,7 @@ static bool blr_send_slave_heartbeat(void* inst)
* @param slave The current slave connection * @param slave The current slave connection
* @return Number of bytes sent or 0 in case of failure * @return Number of bytes sent or 0 in case of failure
*/ */
static int blr_slave_send_heartbeat(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave) static void send_heartbeat(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
{ {
REP_HEADER hdr; REP_HEADER hdr;
GWBUF* h_event; GWBUF* h_event;
@ -6255,10 +6253,7 @@ static int blr_slave_send_heartbeat(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave
* *
* Total = 5 bytes + len * Total = 5 bytes + len
*/ */
if ((h_event = gwbuf_alloc(MYSQL_HEADER_LEN + 1 + len)) == NULL) h_event = gwbuf_alloc(MYSQL_HEADER_LEN + 1 + len);
{
return 0;
}
/* The OK/Err byte is part of payload */ /* The OK/Err byte is part of payload */
hdr.payload_len = len + 1; hdr.payload_len = len + 1;
@ -6306,11 +6301,15 @@ static int blr_slave_send_heartbeat(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave
} }
/* Write the packet */ /* Write the packet */
MXS_SESSION_ROUTE_REPLY(slave->dcb->session, h_event);
}
static void blr_slave_send_heartbeat(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
{
mxs::RoutingWorker* worker = (mxs::RoutingWorker*)slave->dcb->poll.owner; mxs::RoutingWorker* worker = (mxs::RoutingWorker*)slave->dcb->poll.owner;
worker->execute([slave, h_event]() { worker->execute([router, slave]() {
MXS_SESSION_ROUTE_REPLY(slave->dcb->session, h_event); send_heartbeat(router, slave);
}, mxs::RoutingWorker::EXECUTE_AUTO); }, mxs::RoutingWorker::EXECUTE_AUTO);
return 1;
} }
/** /**