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

Commit 9a03b87

Browse files
committed
add traces
1 parent 797c13f commit 9a03b87

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

arbiter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ static void MtmTransReceiver(Datum arg)
853853
if (MtmIsCoordinator(ts)) {
854854
switch (msg->code) {
855855
case MSG_READY:
856+
MTM_TXTRACE(ts, "MtmTransReceiver got MSG_READY");
856857
if (ts->nVotes >= Mtm->nLiveNodes) {
857858
MtmAbortTransaction(ts);
858859
MtmWakeUpBackend(ts);
@@ -875,6 +876,7 @@ static void MtmTransReceiver(Datum arg)
875876
} else if (MtmUseDtm) {
876877
Assert(ts->status == TRANSACTION_STATUS_IN_PROGRESS);
877878
ts->nVotes = 1; /* I voted myself */
879+
MTM_TXTRACE(ts, "MtmTransReceiver send MSG_PREPARE");
878880
MtmSendNotificationMessage(ts, MSG_PREPARE);
879881
} else {
880882
Assert(ts->status == TRANSACTION_STATUS_IN_PROGRESS);
@@ -894,6 +896,7 @@ static void MtmTransReceiver(Datum arg)
894896
}
895897
break;
896898
case MSG_PREPARED:
899+
MTM_TXTRACE(ts, "MtmTransReceiver got MSG_PREPARED");
897900
if (ts->nVotes >= Mtm->nLiveNodes) {
898901
MtmAbortTransaction(ts);
899902
MtmWakeUpBackend(ts);

multimaster.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,8 @@ MtmCreateTransState(MtmCurrentTrans* x)
707707
/* I am coordinator of transaction */
708708
ts->gtid.xid = x->xid;
709709
ts->gtid.node = MtmNodeId;
710-
ts->gid[0] = '\0';
710+
//ts->gid[0] = '\0';
711+
strcpy(ts->gid, x->gid);
711712
}
712713
return ts;
713714
}
@@ -723,6 +724,7 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
723724
{
724725
MtmTransState* ts;
725726
TransactionId* subxids;
727+
MTM_TXTRACE(x, "PrePrepareTransaction Start");
726728

727729
if (!x->isDistributed) {
728730
return;
@@ -781,7 +783,8 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
781783
MtmAddSubtransactions(ts, subxids, ts->nSubxids);
782784
MTM_LOG3("%d: MtmPrePrepareTransaction prepare commit of %d (gtid.xid=%d, gtid.node=%d, CSN=%ld)",
783785
MyProcPid, x->xid, ts->gtid.xid, ts->gtid.node, ts->csn);
784-
MtmUnlock();
786+
MtmUnlock();
787+
MTM_TXTRACE(x, "PrePrepareTransaction Finish");
785788
}
786789

787790
/*
@@ -809,6 +812,7 @@ static void
809812
MtmPostPrepareTransaction(MtmCurrentTrans* x)
810813
{
811814
MtmTransState* ts;
815+
MTM_TXTRACE(x, "PostPrepareTransaction Start");
812816

813817
if (Mtm->inject2PCError == 2) {
814818
Mtm->inject2PCError = 0;
@@ -844,7 +848,9 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
844848
while (!ts->votingCompleted && Mtm->status == MTM_ONLINE && ts->status != TRANSACTION_STATUS_ABORTED && start + transTimeout >= MtmGetSystemTime())
845849
{
846850
MtmUnlock();
851+
MTM_TXTRACE(x, "PostPrepareTransaction WaitLatch Start");
847852
result = WaitLatch(&MyProc->procLatch, WL_LATCH_SET|WL_TIMEOUT, MtmHeartbeatRecvTimeout);
853+
MTM_TXTRACE(x, "PostPrepareTransaction WaitLatch Finish");
848854
if (result & WL_LATCH_SET) {
849855
ResetLatch(&MyProc->procLatch);
850856
}
@@ -867,6 +873,8 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
867873
Mtm->inject2PCError = 0;
868874
elog(ERROR, "ERROR INJECTION for transaction %d (%s)", x->xid, x->gid);
869875
}
876+
877+
MTM_TXTRACE(x, "PostPrepareTransaction Finish");
870878
}
871879

872880

@@ -1063,8 +1071,9 @@ csn_t MtmGetTransactionCSN(TransactionId xid)
10631071
}
10641072

10651073
void MtmWakeUpBackend(MtmTransState* ts)
1066-
{
1067-
if (!ts->votingCompleted) {
1074+
{
1075+
if (!ts->votingCompleted) {
1076+
MTM_TXTRACE(ts, "MtmWakeUpBackend");
10681077
MTM_LOG3("Wakeup backed procno=%d, pid=%d", ts->procno, ProcGlobal->allProcs[ts->procno].pid);
10691078
ts->votingCompleted = true;
10701079
SetLatch(&ProcGlobal->allProcs[ts->procno].procLatch);

multimaster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define MTM_LOG4(fmt, ...) fprintf(stderr, fmt "\n", ## __VA_ARGS__)
3333
#endif
3434

35+
#define MTM_TXTRACE(tx, event) \
36+
fprintf(stderr, "[MTM_TXTRACE] [%s] [%lld] %s\n", tx->gid, (long long)MtmGetSystemTime(), event)
3537
#define MULTIMASTER_NAME "multimaster"
3638
#define MULTIMASTER_SCHEMA_NAME "mtm"
3739
#define MULTIMASTER_DDL_TABLE "ddl_log"

pglogical_proto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ pglogical_write_commit(StringInfo out, PGLogicalOutputData *data,
178178
if (txn->xact_action != XLOG_XACT_COMMIT) {
179179
pq_sendstring(out, txn->gid);
180180
}
181+
182+
MTM_TXTRACE(txn, "pglogical_write_commit Finish");
181183
}
182184

183185
/*

tests2/docker-entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ if [ "$1" = 'postgres' ]; then
8686
multimaster.conn_strings = '$CONNSTRS'
8787
multimaster.heartbeat_recv_timeout = 1000
8888
multimaster.heartbeat_send_timeout = 250
89+
multimaster.twopc_min_timeout = 40000
8990
EOF
9091

9192
tail -n 20 $PGDATA/postgresql.conf

0 commit comments

Comments
 (0)