| 
      
      
      From: Michael P. <mic...@gm...> - 2014-01-09 05:22:52
      
     | 
| >> According to the stack of the session which holds the TwoPhaseStateLock,
>> the error is in the function of
>> LockGXact:
>>
>> static GlobalTransaction
>> LockGXact(const char *gid, Oid user)
>> {
>>     ......
>>     LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
>>
>>     for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
>>     {
>>         ......
>>         gxact->locking_xid = GetTopTransactionId();
>>
>>         LWLockRelease(TwoPhaseStateLock);
>>
>>         return gxact;
>>     }
>>
>>     LWLockRelease(TwoPhaseStateLock);
>>     ......
>> }
>>
>>
>> GetTopTransactionId() is blocked by acquiring another lock, but it is
>> invoked between the TwoPhaseStatLock's Acquire and Release.
>>
>> To fix it, I just call GetTopTransactionId() before
>> "LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE)" to enable the
>> TopTransactionId can be got directly later.
>>
>> diff --git a/src/backend/access/transam/twophase.c
>> b/src/backend/access/transam/twophase.c
>> index c39d9e6..1312e88 100644
>> --- a/src/backend/access/transam/twophase.c
>> +++ b/src/backend/access/transam/twophase.c
>> @@ -414,6 +414,8 @@ LockGXact(const char *gid, Oid user)
>>  {
>>      int            i;
>>
>> +    GetTopTransactionId();
>> +
>>      LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
>>
>>      for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
>>
>>
>> Any commiter can help to review it and commit it to the Github master
>> branch?
> Can you please provide and patch, which fixes this problem?
The patch is a one-line fix and is in the email content... There is
even an analysis and backtraces. There is enough content to review it.
Regards,
-- 
Michael
 |