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

Commit10f7b9e

Browse files
knizhnikkelvich
authored andcommitted
Fix problem with suspended transaction
1 parent7b14ccc commit10f7b9e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎multimaster.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ void MtmLock(LWLockMode mode)
319319
timestamp_tstart,stop;
320320
start=MtmGetSystemTime();
321321
#endif
322+
if (MyProc==NULL) {/* Can not wait if have no PGPROC. It can happen at process exit. TODO: without lock we can get race condition and corrupt Mtm state */
323+
return;
324+
}
322325
LWLockAcquire((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID],mode);
323326
#ifDEBUG_LEVEL>1
324327
stop=MtmGetSystemTime();
@@ -340,6 +343,9 @@ void MtmUnlock(void)
340343
Assert(Mtm->lastLockHolder==MyProcPid);
341344
return;
342345
}
346+
if (MyProc==NULL) {/* If we have no PGPROC, then lock was not obtained. */
347+
return;
348+
}
343349
Mtm->lastLockHolder=0;
344350
LWLockRelease((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID]);
345351
}
@@ -4584,10 +4590,10 @@ static bool MtmTwoPhaseCommit(MtmCurrentTrans* x)
45844590
MTM_ELOG(WARNING,"Failed to prepare transaction %s (%llu)",x->gid, (long64)x->xid);
45854591
}else {
45864592
CommitTransactionCommand();
4593+
StartTransactionCommand();
45874594
if (x->isSuspended) {
45884595
MTM_ELOG(WARNING,"Transaction %s (%llu) is left in prepared state because coordinator node is not online",x->gid, (long64)x->xid);
45894596
}else {
4590-
StartTransactionCommand();
45914597
Assert(x->isActive);
45924598
if (x->status==TRANSACTION_STATUS_ABORTED) {
45934599
FinishPreparedTransaction(x->gid, false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp