Re: Assertion failure on hot standby - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Assertion failure on hot standby
Date
Msg-id 4CF0052A.9030200@enterprisedb.com
Whole thread Raw
In response to Re: Assertion failure on hot standby  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Assertion failure on hot standby
List pgsql-hackers
On 26.11.2010 20:17, Robert Haas wrote:
> On Fri, Nov 26, 2010 at 10:53 AM, Heikki Linnakangas
> <heikki.linnakangas@enterprisedb.com>  wrote:
>> If you have operation A in the master that currently acquires an
>> AccessExclusiveLock on a table, do you think it's safe for another
>> transaction to peek at the table at the same time?
>
> Beep, time out.  The notion of "at the same time" is extremely fuzzy
> here.  The operations on the master and slave are not simultaneous, or
> anything close to it.

In this context, "at the same time" means "at the same point in WAL".

>> As a concrete example, VACUUM acquires an AccessExclusiveLock when it wants
>> to truncate the relation. A sequential scan running against the table in the
>> standby will get upset, if the startup process replays a truncation record
>> on the table without warning.
>
> This case is similar.  xl_smgr_truncate has only a relfilenode number,
> not a relation OID, so there's no way for the startup process to
> generate a conflicting lock request itself.  But if the standby
> backends locked the relfilenode, or if the xl_smgr_truncate WAL record
> included the relation OID, it would be simple.

If you go down that path, you're going to spend a lot of time thinking 
through every single case that uses an AccessExclusiveLock, ensuring 
that the standby has enough information, and tinkering with the replay 
code to acquire locks at the right moment. And gain what, exactly?

WAL-logging AccessExclusiveLocks is a bit ugly, but it beats having to 
infer that information from other records hands down.

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


pgsql-hackers by date:

Previous
From: Dimitri Fontaine
Date:
Subject: Re: Suggested "easy" TODO: pg_dump --from-list
Next
From: Tom Lane
Date:
Subject: Re: memory leak in libxml2 - fix