Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit811e5ce

Browse files
knizhnikkelvich
authored andcommitted
Add more traces
1 parentffb97f9 commit811e5ce

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

‎multimaster.c

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -694,20 +694,18 @@ MtmCreateTransState(MtmCurrentTrans* x)
694694
{
695695
boolfound;
696696
MtmTransState*ts=hash_search(MtmXid2State,&x->xid,HASH_ENTER,&found);
697-
if (!found) {
698-
ts->status=TRANSACTION_STATUS_IN_PROGRESS;
699-
ts->snapshot=x->snapshot;
700-
ts->isLocal= true;
701-
if (TransactionIdIsValid(x->gtid.xid)) {
702-
Assert(x->gtid.node!=MtmNodeId);
703-
ts->gtid=x->gtid;
704-
strcpy(ts->gid,x->gid);
705-
}else {
706-
/* I am coordinator of transaction */
707-
ts->gtid.xid=x->xid;
708-
ts->gtid.node=MtmNodeId;
709-
ts->gid[0]='\0';
710-
}
697+
ts->status=TRANSACTION_STATUS_IN_PROGRESS;
698+
ts->snapshot=x->snapshot;
699+
ts->isLocal= true;
700+
if (TransactionIdIsValid(x->gtid.xid)) {
701+
Assert(x->gtid.node!=MtmNodeId);
702+
ts->gtid=x->gtid;
703+
strcpy(ts->gid,x->gid);
704+
}else {
705+
/* I am coordinator of transaction */
706+
ts->gtid.xid=x->xid;
707+
ts->gtid.node=MtmNodeId;
708+
ts->gid[0]='\0';
711709
}
712710
returnts;
713711
}
@@ -853,11 +851,11 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
853851
if (!ts->votingCompleted) {
854852
if (ts->status!=TRANSACTION_STATUS_ABORTED) {
855853
MtmAbortTransaction(ts);
856-
elog(WARNING,"Transaction is aborted because of %d msec timeout expiration, prepare time %d msec", (int)transTimeout, (int)USEC_TO_MSEC(ts->csn-x->snapshot));
854+
elog(WARNING,"Transaction%dis aborted because of %d msec timeout expiration, prepare time %d msec",x->xid, (int)transTimeout, (int)USEC_TO_MSEC(ts->csn-x->snapshot));
857855
}
858856
}elseif (nConfigChanges!=Mtm->nConfigChanges) {
859857
MtmAbortTransaction(ts);
860-
elog(WARNING,"Transaction is aborted because cluster configuration is changed during commit");
858+
elog(WARNING,"Transaction%dis aborted because cluster configuration is changed during commit",x->xid);
861859
}
862860
x->status=ts->status;
863861
MTM_LOG3("%d: Result of vote: %d",MyProcPid,ts->status);
@@ -879,9 +877,12 @@ MtmAbortPreparedTransaction(MtmCurrentTrans* x)
879877
MtmLock(LW_EXCLUSIVE);
880878
tm= (MtmTransMap*)hash_search(MtmGid2State,x->gid,HASH_REMOVE,NULL);
881879
Assert(tm!=NULL);
880+
MTM_LOG1("Abort prepared transaction %d with gid='%s' is already aborted",x->xid,x->gid);
882881
MtmAbortTransaction(tm->state);
883882
MtmUnlock();
884883
x->status=TRANSACTION_STATUS_ABORTED;
884+
}else {
885+
MTM_LOG1("Transaction %d with gid='%s' is already aborted",x->xid,x->gid);
885886
}
886887
}
887888

@@ -917,6 +918,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
917918
Assert(Mtm->nActiveTransactions!=0);
918919
Mtm->nActiveTransactions-=1;
919920
}else {
921+
MTM_LOG1("%d: abort transaction %d gid='%s' is called from MtmEndTransaction",MyProcPid,x->xid,x->gid);
920922
MtmAbortTransaction(ts);
921923
}
922924
}
@@ -997,7 +999,7 @@ void MtmJoinTransaction(GlobalTransactionId* gtid, csn_t globalSnapshot)
997999

9981000
voidMtmSetCurrentTransactionGID(charconst*gid)
9991001
{
1000-
MTM_LOG3("Set current transaction GID %s",gid);
1002+
MTM_LOG3("Set current transactionxid=%dGID %s",MtmTx.xid,gid);
10011003
strcpy(MtmTx.gid,gid);
10021004
MtmTx.isDistributed= true;
10031005
MtmTx.isReplicated= true;
@@ -1382,15 +1384,21 @@ bool MtmRefreshClusterStatus(bool nowait)
13821384
MtmCheckQuorum();
13831385
/* Interrupt voting for active transaction and abort them */
13841386
for (ts=Mtm->transListHead;ts!=NULL;ts=ts->next) {
1387+
MTM_LOG3("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d",
1388+
ts->gid,ts->gtid.node,ts->xid,ts->status,ts->gtid.xid);
13851389
if (MtmIsCoordinator(ts)) {
13861390
if (!ts->votingCompleted&&ts->status!=TRANSACTION_STATUS_ABORTED) {
13871391
MtmAbortTransaction(ts);
13881392
MtmWakeUpBackend(ts);
13891393
}
13901394
}elseif (TransactionIdIsValid(ts->gtid.xid)&&BIT_CHECK(disabled,ts->gtid.node-1)) {// coordinator of transaction is on disabled node
1391-
if (ts->gid[0]&&ts->status!=TRANSACTION_STATUS_ABORTED) {
1392-
MtmAbortTransaction(ts);
1393-
FinishPreparedTransaction(ts->gid, false);
1395+
if (ts->gid[0]) {
1396+
if (ts->status==TRANSACTION_STATUS_UNKNOWN||ts->status==TRANSACTION_STATUS_IN_PROGRESS) {
1397+
MTM_LOG1("%d: Abort trasaction %s because its coordinator is at disabled node %d",MyProcPid,ts->gid,ts->gtid.node);
1398+
MtmAbortTransaction(ts);
1399+
MtmTx.status=TRANSACTION_STATUS_ABORTED;/* prevent recursive invocation of MtmAbortPreparedTransaction */
1400+
FinishPreparedTransaction(ts->gid, false);
1401+
}
13941402
}
13951403
}
13961404
}
@@ -1460,6 +1468,7 @@ void MtmOnNodeDisconnect(int nodeId)
14601468
}elseif (TransactionIdIsValid(ts->gtid.xid)&&ts->gtid.node==nodeId) {//coordinator of transaction is on disabled node
14611469
if (ts->gid[0]&&ts->status!=TRANSACTION_STATUS_ABORTED) {
14621470
MtmAbortTransaction(ts);
1471+
MtmTx.status=TRANSACTION_STATUS_ABORTED;/* prevent recursive invocation of MtmAbortPreparedTransaction */
14631472
FinishPreparedTransaction(ts->gid, false);
14641473
}
14651474
}

‎pglogical_apply.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ process_remote_commit(StringInfo in)
524524
{
525525
casePGLOGICAL_COMMIT:
526526
{
527-
MTM_LOG3("%d: PGLOGICAL_COMMIT commit",MyProcPid);
527+
MTM_LOG1("%d: PGLOGICAL_COMMIT commit",MyProcPid);
528528
if (IsTransactionState()) {
529529
Assert(TransactionIdIsValid(MtmGetCurrentTransactionId()));
530530
MtmBeginSession();
@@ -537,7 +537,7 @@ process_remote_commit(StringInfo in)
537537
Assert(IsTransactionState()&&TransactionIdIsValid(MtmGetCurrentTransactionId()));
538538
gid=pq_getmsgstring(in);
539539
/* prepare TBLOCK_INPROGRESS state for PrepareTransactionBlock() */
540-
MTM_LOG3("%d: PGLOGICAL_PREPARE commit: gid=%s",MyProcPid,gid);
540+
MTM_LOG1("%d: PGLOGICAL_PREPARE commit: gid=%s",MyProcPid,gid);
541541
BeginTransactionBlock();
542542
CommitTransactionCommand();
543543
StartTransactionCommand();
@@ -554,7 +554,7 @@ process_remote_commit(StringInfo in)
554554
Assert(!TransactionIdIsValid(MtmGetCurrentTransactionId()));
555555
csn=pq_getmsgint64(in);
556556
gid=pq_getmsgstring(in);
557-
MTM_LOG3("%d: PGLOGICAL_COMMIT_PREPARED commit: csn=%ld, gid=%s",MyProcPid,csn,gid);
557+
MTM_LOG1("%d: PGLOGICAL_COMMIT_PREPARED commit: csn=%ld, gid=%s",MyProcPid,csn,gid);
558558
StartTransactionCommand();
559559
MtmBeginSession();
560560
MtmSetCurrentTransactionCSN(csn);
@@ -567,7 +567,7 @@ process_remote_commit(StringInfo in)
567567
{
568568
Assert(!TransactionIdIsValid(MtmGetCurrentTransactionId()));
569569
gid=pq_getmsgstring(in);
570-
MTM_LOG2("%d: PGLOGICAL_ABORT_PREPARED commit: gid=%s",MyProcPid,gid);
570+
MTM_LOG1("%d: PGLOGICAL_ABORT_PREPARED commit: gid=%s",MyProcPid,gid);
571571
if (MtmGetGlobalTransactionStatus(gid)!=TRANSACTION_STATUS_ABORTED) {
572572
MTM_LOG2("%d: PGLOGICAL_ABORT_PREPARED commit: gid=%s #2",MyProcPid,gid);
573573
StartTransactionCommand();

‎pglogical_proto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pglogical_write_commit(StringInfo out, PGLogicalOutputData *data,
160160
}
161161
pq_sendbyte(out,'C');/* sending COMMIT */
162162

163-
MTM_LOG2("PGLOGICAL_SEND commit: event=%d, gid=%s, commit_lsn=%lx, txn->end_lsn=%lx, xlog=%lx",flags,txn->gid,commit_lsn,txn->end_lsn,GetXLogInsertRecPtr());
163+
MTM_LOG1("%ld:PGLOGICAL_SEND commit: event=%d, gid=%s, commit_lsn=%lx, txn->end_lsn=%lx, xlog=%lx",MtmGetSystemTime(),flags,txn->gid,commit_lsn,txn->end_lsn,GetXLogInsertRecPtr());
164164

165165
/* send the flags field */
166166
pq_sendbyte(out,flags);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp