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

Commit26195ab

Browse files
committed
Aff lock graph serializatgion
1 parent1bc810d commit26195ab

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

‎contrib/mmts/multimaster.c‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,3 +1516,73 @@ MtmGetState(void)
15161516
{
15171517
returndtm;
15181518
}
1519+
1520+
staticvoid
1521+
MtmGetGtid(TransactionIdxid,GlobalTransactionId*gtid)
1522+
{
1523+
MtmTransState*ts;
1524+
1525+
MtmLock(LW_SHARED);
1526+
ts= (MtmTransState*)hash_search(xid2state,&xid,HASH_FIND,NULL);
1527+
Assert(ts!=NULL);
1528+
*gtid=ts->gtid;
1529+
MtmUnlock();
1530+
}
1531+
1532+
1533+
staticvoid
1534+
MtmSerializeLock(PROCLOCK*proclock,void*arg)
1535+
{
1536+
ByteBuffer*buf= (ByteBuffer*)arg;
1537+
LOCK*lock=proclock->tag.myLock;
1538+
PGPROC*proc=proclock->tag.myProc;
1539+
GlobalTransactionIdgtid;
1540+
if (lock!=NULL) {
1541+
PGXACT*srcPgXact=&ProcGlobal->allPgXact[proc->pgprocno];
1542+
1543+
if (TransactionIdIsValid(srcPgXact->xid)&&proc->waitLock==lock) {
1544+
LockMethodlockMethodTable=GetLocksMethodTable(lock);
1545+
intnumLockModes=lockMethodTable->numLockModes;
1546+
intconflictMask=lockMethodTable->conflictTab[proc->waitLockMode];
1547+
SHM_QUEUE*procLocks=&(lock->procLocks);
1548+
intlm;
1549+
1550+
MtmGetGtid(srcPgXact->xid,&gtid);/* waiting transaction */
1551+
1552+
ByteBufferAppendInt32(buf,gtid.node);
1553+
ByteBufferAppendInt32(buf,gtid.xid);
1554+
1555+
proclock= (PROCLOCK*)SHMQueueNext(procLocks,procLocks,
1556+
offsetof(PROCLOCK,lockLink));
1557+
while (proclock)
1558+
{
1559+
if (proc!=proclock->tag.myProc) {
1560+
PGXACT*dstPgXact=&ProcGlobal->allPgXact[proclock->tag.myProc->pgprocno];
1561+
if (TransactionIdIsValid(dstPgXact->xid)) {
1562+
Assert(srcPgXact->xid!=dstPgXact->xid);
1563+
for (lm=1;lm <=numLockModes;lm++)
1564+
{
1565+
if ((proclock->holdMask&LOCKBIT_ON(lm))&& (conflictMask&LOCKBIT_ON(lm)))
1566+
{
1567+
MTM_TRACE("%d: %u(%u) waits for %u(%u)\n",getpid(),srcPgXact->xid,proc->pid,dstPgXact->xid,proclock->tag.myProc->pid);
1568+
MtmGetGtid(srcPgXact->xid,&gtid);/* transaction holding lock */
1569+
ByteBufferAppendInt32(buf,gtid.node);
1570+
ByteBufferAppendInt32(buf,gtid.xid);
1571+
break;
1572+
}
1573+
}
1574+
}
1575+
}
1576+
proclock= (PROCLOCK*)SHMQueueNext(procLocks,&proclock->lockLink,
1577+
offsetof(PROCLOCK,lockLink));
1578+
}
1579+
ByteBufferAppendInt32(buf,0);/* end of lock owners list */
1580+
ByteBufferAppendInt32(buf,0);/* end of lock owners list */
1581+
}
1582+
}
1583+
}
1584+
1585+
voidMtmSerializeLockGraph(ByteBuffer*buf)
1586+
{
1587+
EnumerateLocks(MtmSerializeLock,buf);
1588+
}

‎contrib/mmts/multimaster.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,6 @@ extern MtmState* MtmGetState(void);
145145
externtimestamp_tMtmGetCurrentTime(void);
146146
externvoidMtmSleep(timestamp_tinterval);
147147
externboolMtmIsRecoveredNode(intnodeId);
148+
externvoidMtmSerializeLockGraph(ByteBuffer*buf);
149+
148150
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp