Addition of some extra log messages and seconds behind master calcuation
This commit is contained in:
@ -172,6 +172,7 @@ typedef struct router_slave {
|
|||||||
int overrun;
|
int overrun;
|
||||||
uint32_t rank; /*< Replication rank */
|
uint32_t rank; /*< Replication rank */
|
||||||
uint8_t seqno; /*< Replication dump sequence no */
|
uint8_t seqno; /*< Replication dump sequence no */
|
||||||
|
uint32_t lastEventTimestamp;/*< Last event timestamp sent */
|
||||||
SPINLOCK catch_lock; /*< Event catchup lock */
|
SPINLOCK catch_lock; /*< Event catchup lock */
|
||||||
unsigned int cstate; /*< Catch up state */
|
unsigned int cstate; /*< Catch up state */
|
||||||
SPINLOCK rses_lock; /*< Protects rses_deleted */
|
SPINLOCK rses_lock; /*< Protects rses_deleted */
|
||||||
@ -255,6 +256,7 @@ typedef struct router_instance {
|
|||||||
SESSION *session; /*< Fake session for master connection */
|
SESSION *session; /*< Fake session for master connection */
|
||||||
unsigned int master_state; /*< State of the master FSM */
|
unsigned int master_state; /*< State of the master FSM */
|
||||||
uint8_t lastEventReceived;
|
uint8_t lastEventReceived;
|
||||||
|
uint32_t lastEventTimestamp; /*< Timestamp from last event */
|
||||||
GWBUF *residual; /*< Any residual binlog event */
|
GWBUF *residual; /*< Any residual binlog event */
|
||||||
MASTER_RESPONSES saved_master; /*< Saved master responses */
|
MASTER_RESPONSES saved_master; /*< Saved master responses */
|
||||||
char *binlogdir; /*< The directory with the binlog files */
|
char *binlogdir; /*< The directory with the binlog files */
|
||||||
|
@ -361,6 +361,7 @@ unsigned char *defuuid;
|
|||||||
inst->residual = NULL;
|
inst->residual = NULL;
|
||||||
inst->slaves = NULL;
|
inst->slaves = NULL;
|
||||||
inst->next = NULL;
|
inst->next = NULL;
|
||||||
|
inst->lastEventTimestamp = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read any cached response messages
|
* Read any cached response messages
|
||||||
@ -480,6 +481,7 @@ ROUTER_SLAVE *slave;
|
|||||||
slave->file = NULL;
|
slave->file = NULL;
|
||||||
strcpy(slave->binlogfile, "unassigned");
|
strcpy(slave->binlogfile, "unassigned");
|
||||||
slave->connect_time = time(0);
|
slave->connect_time = time(0);
|
||||||
|
slave->lastEventTimestamp = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add this session to the list of active sessions.
|
* Add this session to the list of active sessions.
|
||||||
@ -771,11 +773,18 @@ struct tm tm;
|
|||||||
buf);
|
buf);
|
||||||
dcb_printf(dcb, "\t (%d seconds ago)\n",
|
dcb_printf(dcb, "\t (%d seconds ago)\n",
|
||||||
time(0) - router_inst->stats.lastReply);
|
time(0) - router_inst->stats.lastReply);
|
||||||
dcb_printf(dcb, "\tLast event from master: 0x%x (%s)\n",
|
dcb_printf(dcb, "\tLast event from master: 0x%x, %s",
|
||||||
router_inst->lastEventReceived,
|
router_inst->lastEventReceived,
|
||||||
(router_inst->lastEventReceived >= 0 &&
|
(router_inst->lastEventReceived >= 0 &&
|
||||||
router_inst->lastEventReceived < 0x24) ?
|
router_inst->lastEventReceived < 0x24) ?
|
||||||
event_names[router_inst->lastEventReceived] : "unknown");
|
event_names[router_inst->lastEventReceived] : "unknown");
|
||||||
|
if (router_inst->lastEventTimestamp)
|
||||||
|
{
|
||||||
|
localtime_r(&router_inst->lastEventTimestamp, &tm);
|
||||||
|
asctime_r(&tm, buf);
|
||||||
|
dcb_printf(dcb, "\tLast binlog event timestamp: %ld (%s)\n",
|
||||||
|
router_inst->lastEventTimestamp, buf);
|
||||||
|
}
|
||||||
if (router_inst->active_logs)
|
if (router_inst->active_logs)
|
||||||
dcb_printf(dcb, "\tRouter processing binlog records\n");
|
dcb_printf(dcb, "\tRouter processing binlog records\n");
|
||||||
if (router_inst->reconnect_pending)
|
if (router_inst->reconnect_pending)
|
||||||
@ -859,6 +868,9 @@ struct tm tm;
|
|||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\t\tNo. events sent: %u\n",
|
"\t\tNo. events sent: %u\n",
|
||||||
session->stats.n_events);
|
session->stats.n_events);
|
||||||
|
dcb_printf(dcb,
|
||||||
|
"\t\tNo. bytes sent: %u\n",
|
||||||
|
session->stats.n_bytes);
|
||||||
dcb_printf(dcb,
|
dcb_printf(dcb,
|
||||||
"\t\tNo. bursts sent: %u\n",
|
"\t\tNo. bursts sent: %u\n",
|
||||||
session->stats.n_bursts);
|
session->stats.n_bursts);
|
||||||
@ -884,6 +896,14 @@ struct tm tm;
|
|||||||
dcb_printf(dcb, "\t\tNo. of distribute action 2 %u\n", session->stats.n_actions[1]);
|
dcb_printf(dcb, "\t\tNo. of distribute action 2 %u\n", session->stats.n_actions[1]);
|
||||||
dcb_printf(dcb, "\t\tNo. of distribute action 3 %u\n", session->stats.n_actions[2]);
|
dcb_printf(dcb, "\t\tNo. of distribute action 3 %u\n", session->stats.n_actions[2]);
|
||||||
#endif
|
#endif
|
||||||
|
if (session->lastEventTimestamp
|
||||||
|
&& router_inst->lastEventTimestamp)
|
||||||
|
{
|
||||||
|
localtime_r(&session->lastEventTimestamp, &tm);
|
||||||
|
asctime_r(&tm, buf);
|
||||||
|
dcb_printf(dcb, "\t\tLast binlog event timestamp %u, %s", session->lastEventTimestamp, buf);
|
||||||
|
dcb_printf(dcb, "\t\tSeconds behind master %u\n", router_inst->lastEventTimestamp - session->lastEventTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
if ((session->cstate & CS_UPTODATE) == 0)
|
if ((session->cstate & CS_UPTODATE) == 0)
|
||||||
{
|
{
|
||||||
|
@ -887,6 +887,7 @@ static REP_HEADER phdr;
|
|||||||
}
|
}
|
||||||
router->stats.n_binlogs++;
|
router->stats.n_binlogs++;
|
||||||
router->lastEventReceived = hdr.event_type;
|
router->lastEventReceived = hdr.event_type;
|
||||||
|
router->lastEventTimestamp = hdr.timestamp;
|
||||||
|
|
||||||
// #define SHOW_EVENTS
|
// #define SHOW_EVENTS
|
||||||
#ifdef SHOW_EVENTS
|
#ifdef SHOW_EVENTS
|
||||||
@ -1251,6 +1252,7 @@ int action;
|
|||||||
* this is a rotate event. Send the event directly from
|
* this is a rotate event. Send the event directly from
|
||||||
* memory to the slave.
|
* memory to the slave.
|
||||||
*/
|
*/
|
||||||
|
slave->lastEventTimestamp = hdr->timestamp;
|
||||||
pkt = gwbuf_alloc(hdr->event_size + 5);
|
pkt = gwbuf_alloc(hdr->event_size + 5);
|
||||||
buf = GWBUF_DATA(pkt);
|
buf = GWBUF_DATA(pkt);
|
||||||
encode_value(buf, hdr->event_size + 1, 24);
|
encode_value(buf, hdr->event_size + 1, 24);
|
||||||
|
@ -1326,6 +1326,7 @@ uint8_t *ptr;
|
|||||||
*ptr++ = slave->seqno++;
|
*ptr++ = slave->seqno++;
|
||||||
*ptr++ = 0; // OK
|
*ptr++ = 0; // OK
|
||||||
head = gwbuf_append(head, record);
|
head = gwbuf_append(head, record);
|
||||||
|
slave->lastEventTimestamp = hdr.timestamp;
|
||||||
if (hdr.event_type == ROTATE_EVENT)
|
if (hdr.event_type == ROTATE_EVENT)
|
||||||
{
|
{
|
||||||
unsigned long beat1 = hkheartbeat;
|
unsigned long beat1 = hkheartbeat;
|
||||||
|
Reference in New Issue
Block a user