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

Commit b7b12a1

Browse files
knizhnikkelvich
authored andcommitted
Replace int64 with logn long type to avoid problems with formating
1 parent 6d61a95 commit b7b12a1

9 files changed

+213
-200
lines changed

arbiter.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void MtmSendHeartbeat()
360360
msg.node = MtmNodeId;
361361
msg.csn = now;
362362
if (last_sent_heartbeat != 0 && last_sent_heartbeat + MSEC_TO_USEC(MtmHeartbeatSendTimeout)*2 < now) {
363-
MTM_LOG1("More than %ld microseconds since last heartbeat", now - last_sent_heartbeat);
363+
MTM_LOG1("More than %lld microseconds since last heartbeat", now - last_sent_heartbeat);
364364
}
365365
last_sent_heartbeat = now;
366366

@@ -377,7 +377,7 @@ static void MtmSendHeartbeat()
377377
elog(LOG, "Arbiter failed to send heartbeat to node %d", i+1);
378378
} else {
379379
if (last_heartbeat_to_node[i] + MSEC_TO_USEC(MtmHeartbeatSendTimeout)*2 < now) {
380-
MTM_LOG1("Last heartbeat to node %d was sent %ld microseconds ago", i+1, now - last_heartbeat_to_node[i]);
380+
MTM_LOG1("Last heartbeat to node %d was sent %lld microseconds ago", i+1, now - last_heartbeat_to_node[i]);
381381
}
382382
last_heartbeat_to_node[i] = now;
383383
/* Connectivity mask can be cleared by MtmWatchdog: in this case sockets[i] >= 0 */
@@ -388,7 +388,7 @@ static void MtmSendHeartbeat()
388388
MtmReconnectNode(i+1); /* set reconnect mask to force node reconnent */
389389
//MtmOnNodeConnect(i+1);
390390
}
391-
MTM_LOG4("Send heartbeat to node %d with timestamp %ld", i+1, now);
391+
MTM_LOG4("Send heartbeat to node %d with timestamp %lld", i+1, now);
392392
}
393393
} else {
394394
MTM_LOG2("Do not send heartbeat to node %d, busy mask %lld, status %s", i+1, (long long) busy_mask, MtmNodeStatusMnem[Mtm->status]);
@@ -940,7 +940,7 @@ static void MtmReceiver(Datum arg)
940940

941941
switch (msg->code) {
942942
case MSG_HEARTBEAT:
943-
MTM_LOG4("Receive HEARTBEAT from node %d with timestamp %ld delay %ld",
943+
MTM_LOG4("Receive HEARTBEAT from node %d with timestamp %lld delay %lld",
944944
node, msg->csn, USEC_TO_MSEC(MtmGetSystemTime() - msg->csn));
945945
continue;
946946
case MSG_POLL_REQUEST:
@@ -1017,13 +1017,13 @@ static void MtmReceiver(Datum arg)
10171017
}
10181018
ts = (MtmTransState*)hash_search(MtmXid2State, &msg->dxid, HASH_FIND, NULL);
10191019
if (ts == NULL) {
1020-
elog(WARNING, "Ignore response for unexisted transaction %lu from node %d", (long)msg->dxid, node);
1020+
elog(WARNING, "Ignore response for unexisted transaction %llu from node %d", (long64)msg->dxid, node);
10211021
continue;
10221022
}
10231023
Assert(msg->code == MSG_ABORTED || strcmp(msg->gid, ts->gid) == 0);
10241024
if (BIT_CHECK(ts->votedMask, node-1)) {
1025-
elog(WARNING, "Receive deteriorated %s response for transaction %s (%lu) from node %d",
1026-
MtmMessageKindMnem[msg->code], ts->gid, (long)ts->xid, node);
1025+
elog(WARNING, "Receive deteriorated %s response for transaction %s (%llu) from node %d",
1026+
MtmMessageKindMnem[msg->code], ts->gid, (long64)ts->xid, node);
10271027
continue;
10281028
}
10291029
BIT_SET(ts->votedMask, node-1);
@@ -1033,8 +1033,8 @@ static void MtmReceiver(Datum arg)
10331033
case MSG_PREPARED:
10341034
MTM_TXTRACE(ts, "MtmTransReceiver got MSG_PREPARED");
10351035
if (ts->status == TRANSACTION_STATUS_COMMITTED) {
1036-
elog(WARNING, "Receive PREPARED response for already committed transaction %lu from node %d",
1037-
(long)ts->xid, node);
1036+
elog(WARNING, "Receive PREPARED response for already committed transaction %llu from node %d",
1037+
(long64)ts->xid, node);
10381038
continue;
10391039
}
10401040
Mtm->nodes[node-1].transDelay += MtmGetCurrentTime() - ts->csn;
@@ -1043,8 +1043,8 @@ static void MtmReceiver(Datum arg)
10431043
if ((~msg->disabledNodeMask & Mtm->disabledNodeMask) != 0) {
10441044
/* Coordinator's disabled mask is wider than of this node: so reject such transaction to avoid
10451045
commit on smaller subset of nodes */
1046-
elog(WARNING, "Coordinator of distributed transaction %s (%lu) see less nodes than node %d: %llx instead of %llx",
1047-
ts->gid, (long)ts->xid, node, (long long) Mtm->disabledNodeMask, (long long) msg->disabledNodeMask);
1046+
elog(WARNING, "Coordinator of distributed transaction %s (%llu) see less nodes than node %d: %llx instead of %llx",
1047+
ts->gid, (long64)ts->xid, node, Mtm->disabledNodeMask, msg->disabledNodeMask);
10481048
MtmAbortTransaction(ts);
10491049
}
10501050
if ((ts->participantsMask & ~Mtm->disabledNodeMask & ~ts->votedMask) == 0) {
@@ -1053,7 +1053,7 @@ static void MtmReceiver(Datum arg)
10531053
MtmWakeUpBackend(ts);
10541054
} else {
10551055
Assert(ts->status == TRANSACTION_STATUS_IN_PROGRESS);
1056-
MTM_LOG2("Transaction %s is prepared (status=%s participants=%lx disabled=%lx, voted=%lx)",
1056+
MTM_LOG2("Transaction %s is prepared (status=%s participants=%llx disabled=%llx, voted=%llx)",
10571057
ts->gid, MtmTxnStatusMnem[ts->status], ts->participantsMask, Mtm->disabledNodeMask, ts->votedMask);
10581058
ts->isPrepared = true;
10591059
if (ts->isTwoPhase) {
@@ -1079,12 +1079,12 @@ static void MtmReceiver(Datum arg)
10791079
break;
10801080
case MSG_ABORTED:
10811081
if (ts->status == TRANSACTION_STATUS_COMMITTED) {
1082-
elog(WARNING, "Receive ABORTED response for already committed transaction %s (%lu) from node %d",
1083-
ts->gid, (long)ts->xid, node);
1082+
elog(WARNING, "Receive ABORTED response for already committed transaction %s (%llu) from node %d",
1083+
ts->gid, (long64)ts->xid, node);
10841084
continue;
10851085
}
10861086
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1087-
MTM_LOG1("Arbiter receive abort message for transaction %s (%lu)", ts->gid, (long)ts->xid);
1087+
MTM_LOG1("Arbiter receive abort message for transaction %s (%llu)", ts->gid, (long64)ts->xid);
10881088
Assert(ts->status == TRANSACTION_STATUS_IN_PROGRESS);
10891089
MtmAbortTransaction(ts);
10901090
}
@@ -1095,8 +1095,8 @@ static void MtmReceiver(Datum arg)
10951095
case MSG_PRECOMMITTED:
10961096
MTM_TXTRACE(ts, "MtmTransReceiver got MSG_PRECOMMITTED");
10971097
if (ts->status == TRANSACTION_STATUS_COMMITTED) {
1098-
elog(WARNING, "Receive PRECOMMITTED response for already committed transaction %s (%lu) from node %d",
1099-
ts->gid, (long)ts->xid, node);
1098+
elog(WARNING, "Receive PRECOMMITTED response for already committed transaction %s (%llu) from node %d",
1099+
ts->gid, (long64)ts->xid, node);
11001100
continue;
11011101
}
11021102
if (ts->status == TRANSACTION_STATUS_IN_PROGRESS) {
@@ -1111,8 +1111,8 @@ static void MtmReceiver(Datum arg)
11111111
}
11121112
} else {
11131113
Assert(ts->status == TRANSACTION_STATUS_ABORTED);
1114-
elog(WARNING, "Receive PRECOMMITTED response for aborted transaction %s (%lu) from node %d",
1115-
ts->gid, (long)ts->xid, node); // How it can happen? SHould we use assert here?
1114+
elog(WARNING, "Receive PRECOMMITTED response for aborted transaction %s (%llu) from node %d",
1115+
ts->gid, (long64)ts->xid, node); // How it can happen? SHould we use assert here?
11161116
if ((ts->participantsMask & ~Mtm->disabledNodeMask & ~ts->votedMask) == 0) {
11171117
MtmWakeUpBackend(ts);
11181118
}
@@ -1160,7 +1160,7 @@ static void MtmReceiver(Datum arg)
11601160
if (!MtmWatchdog(now)) {
11611161
for (i = 0; i < nNodes; i++) {
11621162
if (Mtm->nodes[i].lastHeartbeat != 0 && sockets[i] >= 0) {
1163-
MTM_LOG1("Last heartbeat from node %d received %ld microseconds ago", i+1, now - Mtm->nodes[i].lastHeartbeat);
1163+
MTM_LOG1("Last heartbeat from node %d received %lld microseconds ago", i+1, now - Mtm->nodes[i].lastHeartbeat);
11641164
}
11651165
}
11661166
}

bgwpool.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#include "storage/s_lock.h"
55
#include "storage/spin.h"
66
#include "storage/pg_sema.h"
7+
#include "bkb.h"
78

89
typedef void(*BgwPoolExecutor)(void* work, size_t size);
910

10-
typedef uint64 timestamp_t;
11-
typedef long long long64; /* we are not using int64 here because we want to use %lld format for this type */
11+
typedef ulong64 timestamp_t;
12+
1213

1314
#define MAX_DBNAME_LEN 30
1415
#define MAX_DBUSER_LEN 30

bkb.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
#define MAX_NODES 64
88

9-
typedef uint64_t nodemask_t;
9+
typedef long long long64; /* we are not using int64 here because we want to use %lld format for this type */
10+
typedef unsigned long long ulong64; /* we are not using uint64 here because we want to use %lld format for this type */
11+
12+
typedef ulong64 nodemask_t;
13+
1014
#define BIT_CHECK(mask, bit) (((mask) & ((nodemask_t)1 << (bit))) != 0)
1115
#define BIT_CLEAR(mask, bit) (mask &= ~((nodemask_t)1 << (bit)))
1216
#define BIT_SET(mask, bit) (mask |= ((nodemask_t)1 << (bit)))

bkbtest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main() {
1111
matrix[2] = 1;
1212
matrix[4] = 3;
1313
clique = MtmFindMaxClique(matrix, 64, &clique_size);
14-
printf("Clique=%lx\n", clique);
14+
printf("Clique=%llx\n", clique);
1515
return 0;
1616
}
1717

0 commit comments

Comments
 (0)