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

Commit 995648f

Browse files
committed
Fix locking in MtmRefreshClusterStatus
1 parent 0812669 commit 995648f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

contrib/mmts/arbiter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static void MtmSendHeartbeat()
354354
msg.oldestSnapshot = Mtm->nodes[MtmNodeId-1].oldestSnapshot;
355355
msg.node = MtmNodeId;
356356
msg.csn = now;
357-
if (last_sent_heartbeat + MSEC_TO_USEC(MtmHeartbeatSendTimeout)*2 < now) {
357+
if (last_sent_heartbeat != 0 && last_sent_heartbeat + MSEC_TO_USEC(MtmHeartbeatSendTimeout)*2 < now) {
358358
MTM_LOG1("More than %ld microseconds since last heartbeat", now - last_sent_heartbeat);
359359
}
360360
last_sent_heartbeat = now;
@@ -1024,7 +1024,7 @@ static void MtmTransReceiver(Datum arg)
10241024
MTM_LOG1("Last hearbeat from node %d received %ld microseconds ago", i+1, now - Mtm->nodes[i].lastHeartbeat);
10251025
}
10261026
}
1027-
MTM_LOG1("epoll started %ld and finished %ld microseconds ago", now - startPolling, now - stopPolling);
1027+
MTM_LOG2("epoll started %ld and finished %ld microseconds ago", now - startPolling, now - stopPolling);
10281028
}
10291029
lastHeartbeatCheck = now;
10301030
}

contrib/mmts/multimaster.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ MtmAdjustOldestXid(TransactionId xid)
568568
if (MtmUseDtm)
569569
{
570570
if (prev != NULL) {
571-
MTM_LOG1("%d: MtmAdjustOldestXid: oldestXid=%d, prev->xid=%d, prev->status=%d, prev->snapshot=%ld, ts->xid=%d, ts->status=%d, ts->snapshot=%ld, oldestSnapshot=%ld",
571+
MTM_LOG2("%d: MtmAdjustOldestXid: oldestXid=%d, prev->xid=%d, prev->status=%d, prev->snapshot=%ld, ts->xid=%d, ts->status=%d, ts->snapshot=%ld, oldestSnapshot=%ld",
572572
MyProcPid, xid, prev->xid, prev->status, prev->snapshot, (ts ? ts->xid : 0), (ts ? ts->status : -1), (ts ? ts->snapshot : -1), oldestSnapshot);
573573
Mtm->transListHead = prev;
574574
Mtm->oldestXid = xid = prev->xid;
@@ -887,7 +887,7 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
887887
MtmLock(LW_EXCLUSIVE);
888888
ts = hash_search(MtmXid2State, &x->xid, HASH_FIND, NULL);
889889
Assert(ts != NULL);
890-
if (x->gid[0]) MTM_LOG1("Preparing transaction %d (%s) at %ld", x->xid, x->gid, MtmGetCurrentTime());
890+
//if (x->gid[0]) MTM_LOG1("Preparing transaction %d (%s) at %ld", x->xid, x->gid, MtmGetCurrentTime());
891891
if (!MtmIsCoordinator(ts) || Mtm->status == MTM_RECOVERY) {
892892
bool found;
893893
MtmTransMap* tm = (MtmTransMap*)hash_search(MtmGid2State, x->gid, HASH_ENTER, &found);
@@ -941,7 +941,7 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
941941
MTM_LOG3("%d: Result of vote: %d", MyProcPid, ts->status);
942942
MtmUnlock();
943943
}
944-
if (x->gid[0]) MTM_LOG1("Prepared transaction %d (%s) csn=%ld at %ld: %d", x->xid, x->gid, ts->csn, MtmGetCurrentTime(), ts->status);
944+
//if (x->gid[0]) MTM_LOG1("Prepared transaction %d (%s) csn=%ld at %ld: %d", x->xid, x->gid, ts->csn, MtmGetCurrentTime(), ts->status);
945945
if (Mtm->inject2PCError == 3) {
946946
Mtm->inject2PCError = 0;
947947
elog(ERROR, "ERROR INJECTION for transaction %d (%s)", x->xid, x->gid);
@@ -2597,7 +2597,9 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
25972597
} else {
25982598
MtmUnlock();
25992599
MtmRefreshClusterStatus(true);
2600+
MtmLock(LW_SHARED);
26002601
if (BIT_CHECK(Mtm->disabledNodeMask, MtmReplicationNodeId-1)) {
2602+
MtmUnlock();
26012603
elog(ERROR, "Disabled node %d tries to reconnect without recovery", MtmReplicationNodeId);
26022604
}
26032605
}

contrib/mmts/pglogical_apply.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ process_remote_begin(StringInfo s)
343343

344344
inside_tx = true;
345345

346-
MTM_LOG1("REMOTE begin node=%d xid=%d snapshot=%ld", gtid.node, gtid.xid, snapshot);
346+
MTM_LOG2("REMOTE begin node=%d xid=%d snapshot=%ld", gtid.node, gtid.xid, snapshot);
347347
}
348348

349349
static void
@@ -624,7 +624,7 @@ process_remote_commit(StringInfo in)
624624
gid = pq_getmsgstring(in);
625625
MTM_LOG2("PGLOGICAL_ABORT_PREPARED commit: gid=%s", gid);
626626
if (MtmExchangeGlobalTransactionStatus(gid, TRANSACTION_STATUS_ABORTED) == TRANSACTION_STATUS_UNKNOWN) {
627-
MTM_LOG1("PGLOGICAL_ABORT_PREPARED commit: gid=%s #2", gid);
627+
MTM_LOG2("PGLOGICAL_ABORT_PREPARED commit: gid=%s #2", gid);
628628
StartTransactionCommand();
629629
MtmBeginSession();
630630
MtmSetCurrentTransactionGID(gid);
@@ -967,7 +967,7 @@ void MtmExecutor(int id, void* work, size_t size)
967967
{
968968
while (true) {
969969
char action = pq_getmsgbyte(&s);
970-
MTM_LOG1("%d: REMOTE process action %c", MyProcPid, action);
970+
MTM_LOG2("%d: REMOTE process action %c", MyProcPid, action);
971971
#if 0
972972
if (Mtm->status == MTM_RECOVERY) {
973973
MTM_LOG1("Replay action %c[%x]", action, s.data[s.cursor]);

0 commit comments

Comments
 (0)