Re: Assertion failure on hot standby

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Subject: Re: Assertion failure on hot standby
Date: 2010-11-26 15:28:38
Message-ID: AANLkTikqGESwOdCMT8UXjuVBYjASXsK54KW3iy-yk-xe@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 26, 2010 at 7:41 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> On Friday 26 November 2010 13:32:18 Robert Haas wrote:
>> On Fri, Nov 26, 2010 at 1:11 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> > Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
>> >> That would mean running GetCurrentTransactionId() inside LockAcquire()
>> >>
>> >> if (lockmode >= AccessExclusiveLock &&
>> >>     locktag->locktag_type == LOCKTAG_RELATION &&
>> >>     !RecoveryInProgress())
>> >>       (void) GetCurrentTransactionId();
>> >>
>> >> Any objections to that fix?
>> >
>> > Could we have a wal level test in there too please?  It's pretty awful
>> > in any case...
>> Incidentally, I haven't been able to wrap my head around why we need
>> to propagate AccessExclusiveLocks to the standby in the first place.
>> Can someone explain?
> To make the standby stop applying WAL when a local transaction on the standby
> uses an object.
> E.g. dropping a table on the master need the standby top stop applying wal (or
> kill the local client using the table).
> How would you want to protect against something like that otherwise?

Hmm. But it seems like that it would be enough to log any exclusive
locks held at commit time, rather than logging them as they're
acquired. By then, the XID will be assigned (if you need it - if you
don't then you probably don't need to XLOG it anyway) and you avoid
holding the lock for more than a moment on the standby.

But it seems like an even better idea would be to actually XLOG the
operations that are problematic specifically. Because, for example,
if a user session on the master does LOCK TABLE ... IN ACCESS
EXCLUSIVE MODE, AFAICS there's no reason for the standby to care. Or
am I confused?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2010-11-26 15:53:29 Re: Assertion failure on hot standby
Previous Message Kris Jurka 2010-11-26 15:25:01 Re: Workarounds for getBinaryStream returning ByteArrayInputStream on bytea