Re: Hot Standby and prepared transactions

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Hiroyuki Yamada <yamada(at)kokolink(dot)net>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hot Standby and prepared transactions
Date: 2009-12-16 11:13:56
Message-ID: 4B28C0F4.3080806@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hiroyuki Yamada wrote:
> By the way, reading LogStandbySnapshot() and GetRunningTransactionLocks()
> raised following questions.
>
> * 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 ?

Hmm, when replying the locks record, we should be ignoring entries
belonging to already-committed transactions. But I don't actually see
that in the code. That needs to be fixed, I think.

> Similary,
>
> * There is a window beween writing COMMIT WAL in RecordTransactionCommit() and
> releasing locks in ResourceOwnerRelease()
>
> ... then what happens when GetRunningTransactionLocks() gathers ACCESS EXCLUSIVE
> locks whose holder has already written the COMMIT WAL ?

This is handled in standby in the same manner as the above case.

> Are there any chances of releasing locks which have no COMMIT WAL for releasing them ?

Yes. In normal operation, there should eventually be a commit or abort
WAL record for every transaction. But as a safety valve, when a
running-xacts record is replayed, we mark as aborted all transactions
that are older than the oldest still-running XID according to the
running-xacts record, and release their locks. See StandbyReleaseOldLocks().

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Albe Laurenz 2009-12-16 12:06:24 Re: Update on true serializable techniques in MVCC
Previous Message Boszormenyi Zoltan 2009-12-16 10:54:41 Re: ECPG patch N+1, fix auto-prepare