Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 34905fc

Browse files
knizhnikkelvich
authored andcommitted
Count number of received heartbeast for statustic
1 parent 29874a5 commit 34905fc

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

arbiter.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -949,13 +949,14 @@ static void MtmReceiver(Datum arg)
949949
Mtm->nodes[node-1].lastHeartbeat = MtmGetSystemTime();
950950

951951
MtmCheckResponse(msg);
952-
MTM_LOG2("Receive response %s for transaction %s from node %d", MtmMessageKindMnem[msg->code], msg->gid, msg->node);
952+
MTM_LOG2("Receive response %s for transaction %s from node %d", MtmMessageKindMnem[msg->code], msg->gid, node);
953953

954954
switch (msg->code) {
955955
case MSG_HEARTBEAT:
956956
MTM_LOG4("Receive HEARTBEAT from node %d with timestamp %lld delay %lld",
957957
node, msg->csn, USEC_TO_MSEC(MtmGetSystemTime() - msg->csn));
958-
continue;
958+
Mtm->nodes[node-1].nHeartbeats += 1;
959+
continue;
959960
case MSG_POLL_REQUEST:
960961
Assert(*msg->gid);
961962
tm = (MtmTransMap*)hash_search(MtmGid2State, msg->gid, HASH_FIND, NULL);
@@ -965,7 +966,7 @@ static void MtmReceiver(Datum arg)
965966
} else {
966967
msg->status = tm->state->status;
967968
msg->csn = tm->state->csn;
968-
MTM_LOG1("Send response %s for transaction %s to node %d", MtmTxnStatusMnem[msg->status], msg->gid, msg->node);
969+
MTM_LOG1("Send response %s for transaction %s to node %d", MtmTxnStatusMnem[msg->status], msg->gid, node);
969970
}
970971
msg->disabledNodeMask = Mtm->disabledNodeMask;
971972
msg->connectivityMask = SELF_CONNECTIVITY_MASK;

multimaster--1.0.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ AS 'MODULE_PATHNAME','mtm_get_last_csn'
3636
LANGUAGE C;
3737

3838

39-
CREATE TYPE mtm.node_state AS ("id" integer, "disabled" bool, "disconnected" bool, "catchUp" bool, "slotLag" bigint, "avgTransDelay" bigint, "lastStatusChange" timestamp, "oldestSnapshot" bigint, "SenderPid" integer, "SenderStartTime" timestamp, "ReceiverPid" integer, "ReceiverStartTime" timestamp, "connStr" text, "connectivityMask" bigint, "stalled" bool, "stopped" bool);
39+
CREATE TYPE mtm.node_state AS ("id" integer, "disabled" bool, "disconnected" bool, "catchUp" bool, "slotLag" bigint, "avgTransDelay" bigint, "lastStatusChange" timestamp, "oldestSnapshot" bigint, "SenderPid" integer, "SenderStartTime" timestamp, "ReceiverPid" integer, "ReceiverStartTime" timestamp, "connStr" text, "connectivityMask" bigint, "stalled" bool, "stopped" bool, "nHeartbeats" bigint);
4040

4141
CREATE FUNCTION mtm.get_nodes_state() RETURNS SETOF mtm.node_state
4242
AS 'MODULE_PATHNAME','mtm_get_nodes_state'

multimaster.c

+2
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,7 @@ static void MtmInitialize()
24872487
Mtm->nodes[i].restartLSN = INVALID_LSN;
24882488
Mtm->nodes[i].originId = InvalidRepOriginId;
24892489
Mtm->nodes[i].timeline = 0;
2490+
Mtm->nodes[i].nHeartbeats = 0;
24902491
}
24912492
Mtm->nodes[MtmNodeId-1].originId = DoNotReplicateId;
24922493
/* All transaction originated from the current node should be ignored during recovery */
@@ -3975,6 +3976,7 @@ mtm_get_nodes_state(PG_FUNCTION_ARGS)
39753976
usrfctx->values[13] = Int64GetDatum(Mtm->nodes[usrfctx->nodeId-1].connectivityMask);
39763977
usrfctx->values[14] = BoolGetDatum(BIT_CHECK(Mtm->stalledNodeMask, usrfctx->nodeId-1));
39773978
usrfctx->values[15] = BoolGetDatum(BIT_CHECK(Mtm->stoppedNodeMask, usrfctx->nodeId-1));
3979+
usrfctx->values[16] = Int64GetDatum(Mtm->nodes[usrfctx->nodeId-1].nHeartbeats);
39783980
usrfctx->nodeId += 1;
39793981

39803982
SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(heap_form_tuple(usrfctx->desc, usrfctx->values, usrfctx->nulls)));

multimaster.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
#define Anum_mtm_local_tables_rel_name 2
8585

8686
#define Natts_mtm_trans_state 15
87-
#define Natts_mtm_nodes_state 16
87+
#define Natts_mtm_nodes_state 17
8888
#define Natts_mtm_cluster_state 19
8989

9090
typedef ulong64 csn_t; /* commit serial number */
@@ -226,6 +226,7 @@ typedef struct
226226
void* lockGraphData;
227227
int lockGraphAllocated;
228228
int lockGraphUsed;
229+
uint64 nHeartbeats;
229230
} MtmNodeInfo;
230231

231232
typedef struct MtmL2List

0 commit comments

Comments
 (0)