Re: ALTER TABLE lock strength reduction patch is unsafe - Mailing list pgsql-hackers

From Noah Misch
Subject Re: ALTER TABLE lock strength reduction patch is unsafe
Date
Msg-id 20120102192525.GB23436@tornado.leadboat.com
Whole thread Raw
In response to Re: ALTER TABLE lock strength reduction patch is unsafe  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: ALTER TABLE lock strength reduction patch is unsafe  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
On Mon, Jan 02, 2012 at 06:41:31PM +0000, Simon Riggs wrote:
> On Mon, Jan 2, 2012 at 6:06 PM, Noah Misch <noah@leadboat.com> wrote:
> > On Mon, Jan 02, 2012 at 05:09:16PM +0000, Simon Riggs wrote:
> >> Attached patch makes SnapshotNow into an MVCC snapshot, initialised at
> >> the start of each scan iff SnapshotNow is passed as the scan's
> >> snapshot. It's fairly brief but seems to do the trick.
> >
> > That's a neat trick. ?However, if you start a new SnapshotNow scan while one is
> > ongoing, the primordial scan's snapshot will change mid-stream.
>
> Do we ever do that? (and if so, Why?!? or perhaps just Where?)

I hacked up your patch a bit, as attached, to emit a WARNING for any nested
use of SnapshotNow.  This made 97/127 test files fail.  As one example,
RelationBuildRuleLock() does TextDatumGetCString() for every tuple of its
SnapshotNow scan.  That may need a detoast, which itself runs a scan.

> We can use more complex code if required, but we'll be adding
> complexity and code into the main path that I'd like to avoid.

Agreed.

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ALTER TABLE lock strength reduction patch is unsafe
Next
From: Magnus Hagander
Date:
Subject: Re: backup_label during crash recovery: do we know how to solve it?