@@ -278,13 +278,13 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
278
278
{
279
279
if (ts -> csn > dtmTx .snapshot ) {
280
280
MTM_TUPLE_TRACE ("%d: tuple with xid=%d(csn=%ld) is invisibile in snapshot %ld\n" ,
281
- getpid () ,xid ,ts -> csn ,dtmTx .snapshot );
281
+ MyProcPid ,xid ,ts -> csn ,dtmTx .snapshot );
282
282
MtmUnlock ();
283
283
return true;
284
284
}
285
285
if (ts -> status == TRANSACTION_STATUS_UNKNOWN )
286
286
{
287
- MTM_TRACE ("%d: wait for in-doubt transaction %u in snapshot %lu\n" ,getpid () ,xid ,dtmTx .snapshot );
287
+ MTM_TRACE ("%d: wait for in-doubt transaction %u in snapshot %lu\n" ,MyProcPid ,xid ,dtmTx .snapshot );
288
288
MtmUnlock ();
289
289
#if TRACE_SLEEP_TIME
290
290
{
@@ -316,14 +316,14 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
316
316
{
317
317
bool invisible = ts -> status != TRANSACTION_STATUS_COMMITTED ;
318
318
MTM_TUPLE_TRACE ("%d: tuple with xid=%d(csn= %ld) is %s in snapshot %ld\n" ,
319
- getpid () ,xid ,ts -> csn ,invisible ?"rollbacked" :"committed" ,dtmTx .snapshot );
319
+ MyProcPid ,xid ,ts -> csn ,invisible ?"rollbacked" :"committed" ,dtmTx .snapshot );
320
320
MtmUnlock ();
321
321
return invisible ;
322
322
}
323
323
}
324
324
else
325
325
{
326
- MTM_TUPLE_TRACE ("%d: visibility check is skept for transaction %u in snapshot %lu\n" ,getpid () ,xid ,dtmTx .snapshot );
326
+ MTM_TUPLE_TRACE ("%d: visibility check is skept for transaction %u in snapshot %lu\n" ,MyProcPid ,xid ,dtmTx .snapshot );
327
327
break ;
328
328
}
329
329
}
@@ -493,7 +493,7 @@ MtmXactCallback(XactEvent event, void *arg)
493
493
static bool
494
494
MtmIsUserTransaction ()
495
495
{
496
- return IsNormalProcessingMode ()&& dtm -> status == MTM_ONLINE && MtmDoReplication && !am_walsender && !IsBackgroundWorker && !IsAutoVacuumWorkerProcess ();
496
+ return IsNormalProcessingMode ()&& MtmDoReplication && !am_walsender && !IsBackgroundWorker && !IsAutoVacuumWorkerProcess ();
497
497
}
498
498
499
499
static void
@@ -504,6 +504,10 @@ MtmBeginTransaction(MtmCurrentTrans* x)
504
504
x -> xid = GetCurrentTransactionIdIfAny ();
505
505
x -> isReplicated = false;
506
506
x -> isDistributed = MtmIsUserTransaction ();
507
+ if (x -> isDistributed && dtm -> status != MTM_ONLINE ) {
508
+ MtmUnlock ();
509
+ elog (ERROR ,"Multimaster node is offline" );
510
+ }
507
511
x -> containsDML = false;
508
512
x -> isPrepared = false;
509
513
x -> snapshot = MtmAssignCSN ();
@@ -614,7 +618,7 @@ static void MtmPrecommitTransaction(MtmCurrentTrans* x)
614
618
615
619
MtmUnlock ();
616
620
617
- MTM_TRACE ("%d: MtmPrepareTransaction prepare commit of %d CSN=%ld\n" ,getpid () ,x -> xid ,ts -> csn );
621
+ MTM_TRACE ("%d: MtmPrepareTransaction prepare commit of %d CSN=%ld\n" ,MyProcPid ,x -> xid ,ts -> csn );
618
622
}
619
623
620
624
static void
@@ -728,14 +732,14 @@ MtmCommitTransaction(TransactionId xid, int nsubxids, TransactionId *subxids)
728
732
ts = hash_search (xid2state ,& xid ,HASH_FIND ,NULL );
729
733
Assert (ts != NULL );/* should be created by MtmPrepareTransaction */
730
734
731
- MTM_TRACE ("%d: MtmCommitTransaction begin commit of %d CSN=%ld\n" ,getpid () ,xid ,ts -> csn );
735
+ MTM_TRACE ("%d: MtmCommitTransaction begin commit of %d CSN=%ld\n" ,MyProcPid ,xid ,ts -> csn );
732
736
MtmAddSubtransactions (ts ,subxids ,nsubxids );
733
737
734
738
MtmVoteForTransaction (ts );
735
739
736
740
MtmUnlock ();
737
741
738
- MTM_TRACE ("%d: MtmCommitTransaction %d status=%d\n" ,getpid () ,xid ,ts -> status );
742
+ MTM_TRACE ("%d: MtmCommitTransaction %d status=%d\n" ,MyProcPid ,xid ,ts -> status );
739
743
740
744
return ts -> status != TRANSACTION_STATUS_ABORTED ;
741
745
}
@@ -768,7 +772,7 @@ MtmFinishTransaction(TransactionId xid, int nsubxids, TransactionId *subxids, Xi
768
772
MtmSendNotificationMessage (ts );
769
773
}
770
774
MtmUnlock ();
771
- MTM_TRACE ("%d: MtmFinishTransaction %d CSN=%ld, status=%d\n" ,getpid () ,xid ,ts -> csn ,status );
775
+ MTM_TRACE ("%d: MtmFinishTransaction %d CSN=%ld, status=%d\n" ,MyProcPid ,xid ,ts -> csn ,status );
772
776
}
773
777
}
774
778
@@ -777,7 +781,7 @@ MtmFinishTransaction(TransactionId xid, int nsubxids, TransactionId *subxids, Xi
777
781
static void
778
782
MtmSetTransactionStatus (TransactionId xid ,int nsubxids ,TransactionId * subxids ,XidStatus status ,XLogRecPtr lsn )
779
783
{
780
- MTM_TRACE ("%d: MtmSetTransactionStatus %u(%u) = %u, isDistributed=%d\n" ,getpid () ,xid ,dtmTx .xid ,status ,dtmTx .isDistributed );
784
+ MTM_TRACE ("%d: MtmSetTransactionStatus %u(%u) = %u, isDistributed=%d\n" ,MyProcPid ,xid ,dtmTx .xid ,status ,dtmTx .isDistributed );
781
785
if (xid == dtmTx .xid && dtmTx .isDistributed && !dtmTx .isPrepared )
782
786
{
783
787
if (status == TRANSACTION_STATUS_ABORTED || !dtmTx .containsDML || dtm -> status == MTM_RECOVERY )
@@ -1100,7 +1104,7 @@ void MtmReceiverStarted(int nodeId)
1100
1104
{
1101
1105
SpinLockAcquire (& dtm -> spinlock );
1102
1106
if (!BIT_CHECK (dtm -> pglogicalNodeMask ,nodeId - 1 )) {
1103
- dtm -> pglogicalNodeMask |= (int64 )1 << (nodeId - 1 );
1107
+ dtm -> pglogicalNodeMask |= (nodemask_t )1 << (nodeId - 1 );
1104
1108
if (++ dtm -> nReceivers == dtm -> nNodes - 1 ) {
1105
1109
elog (WARNING ,"All receivers are started, switch to normal mode" );
1106
1110
Assert (dtm -> status == MTM_CONNECTED );
@@ -1478,14 +1482,14 @@ MtmVoteForTransaction(MtmTransState* ts)
1478
1482
MtmSendNotificationMessage (ts );
1479
1483
}
1480
1484
}
1481
- MTM_TRACE ("%d: Node %d waiting latch...\n" ,getpid () ,MtmNodeId );
1485
+ MTM_TRACE ("%d: Node %d waiting latch...\n" ,MyProcPid ,MtmNodeId );
1482
1486
while (!ts -> done ) {
1483
1487
MtmUnlock ();
1484
1488
WaitLatch (& MyProc -> procLatch ,WL_LATCH_SET ,-1 );
1485
1489
ResetLatch (& MyProc -> procLatch );
1486
1490
MtmLock (LW_SHARED );
1487
1491
}
1488
- MTM_TRACE ("%d: Node %d receives response...\n" ,getpid () ,MtmNodeId );
1492
+ MTM_TRACE ("%d: Node %d receives response...\n" ,MyProcPid ,MtmNodeId );
1489
1493
}
1490
1494
1491
1495
HTAB * MtmCreateHash (void )