Re: Hot Standby and prepared transactions

Hiroyuki Yamada <yamada@kokolink.net>

From: Hiroyuki Yamada <yamada@kokolink.net>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>, pgsql-hackers@postgresql.org
Date: 2009-12-17T10:55:36Z
Lists: pgsql-hackers
>On Wed, 2009-12-16 at 19:35 +0900, Hiroyuki Yamada wrote:
>
>>  * There is a window beween gathering lock information in GetRunningTransactionLocks()
>>    and writing WAL in LogAccessExclusiveLocks().
>>  * In current lock redo algorithm, locks are released when the transaction holding the lock
>>    are commited or aborted.
>> 
>> ... then what happens if any transaction holding ACCESS EXCLUSIVE lock commits in the 
>>    window ?
>
>Yes, was a problem in that code. Fixed in git.
>
>We were doing it for prepared transactions but not for normal xacts.
>I will look again at that code.
>
>Thanks very much for reading the code. Any more?!?
>

Well, I've read some more and have a question.

The implementation assumes that transactions write COMMIT/ABORT WAL at the end
of them, while it does not seem to write ABORT WAL in immediate shutdown. So,

1. acquire ACCESS EXCLUSIVE lock in table A in xact 1
2. execute immediate shutdown of the active node
3. restart it
4. acquire ACCESS EXCLUSIVE lock in table A in xact 2

...then, duplicate lock acquisition by two diffrent transactions can occur in the standby node.

Am I missing something ? Or is this already reported ?


regards,

--
  Hiroyuki YAMADA
  Kokolink Corporation
  yamada@kokolink.net