Re: max_standby_delay considered harmful

From: Andres Freund <andres(at)anarazel(dot)de>
To: Florian Pflug <fgp(at)phlo(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Dimitri Fontaine <dfontaine(at)hi-media(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <greg(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>
Subject: Re: max_standby_delay considered harmful
Date: 2010-05-09 22:58:30
Message-ID: 201005100058.31428.andres@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Monday 10 May 2010 00:25:44 Florian Pflug wrote:
> On May 9, 2010, at 22:01 , Robert Haas wrote:
> > On Sun, May 9, 2010 at 3:09 PM, Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
wrote:
> >> Florian Pflug <fgp(at)phlo(dot)org> writes:
> >>> The only remaining option is to continue applying WAL until you reach
> >>> a point where no locks are held, then pause. But from a user's POV
> >>> that is nearly indistinguishable from simply setting
> >>> hot_standby_conflict_winner to in the first place I think.
> >>
> >> Not really, the use case would be using the slave as a reporting server,
> >> you know you have say 4 hours of reporting queries during which you will
> >> pause the recovery. So it's ok for the pause command to take time.
> >
> > Seems like it could take FOREVER on a busy system. Surely that's not
> > OK. The fact that Hot Standby has to take exclusive locks that can't
> > be released until WAL replay has progressed to a certain point seems
> > like a fairly serious wart.
>
> If this is a serious wart then it's not one of hot standby, but one of
> postgres proper. AccessExclusiveLocks (SELECT-blocking locks that is, as
> opposed to UPDATE/DELETE-blocking locks) are never necessary from a
> correctness POV, they're only there for implementation reasons.
>
> Getting rid of them doesn't seem completely insurmountable either - just as
> multiple row versions remove the need to block SELECTs dues to concurrent
> UPDATEs, multiple datafile versions could remove the need to block SELECTs
> due to concurrent ALTERs. But people seem to live with them quite well,
> judged from the amount of work put into getting rid of them (zero). I
> therefore fail to see why they should pose a significant problem in HS
> setups.
The difference is that in HS you have to wait for a moment where *no exclusive
lock at all* exist, possibly without contending for any of them, while on the
master you might not even blocked by the existence of any of those locks.

If you have two sessions which in overlapping transactions lock different
tables exlusively you have no problem shutting the master down, but you will
never reach a point where no exclusive lock is taken on the slave.

Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ian Barwick 2010-05-10 00:46:48 Re: 9.0b1: "ERROR: btree index keys must be ordered by attribute"
Previous Message Florian Pflug 2010-05-09 22:25:44 Re: max_standby_delay considered harmful