Re: First-draft release notes for next week's releases

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, Greg Stark <stark(at)mit(dot)edu>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: First-draft release notes for next week's releases
Date: 2014-03-17 20:39:19
Message-ID: 20140317203919.GR16438@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-03-17 16:17:35 -0300, Alvaro Herrera wrote:
> Andres Freund wrote:
> > On 2014-03-17 14:01:03 -0400, Tom Lane wrote:
> > > Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > > > * I wonder if we should make the possible origins a bit more
> > > > general as it's perfectly possible to trigger the problem without
> > > > foreign keys. Maybe: "can arise when a table row that has been updated
> > > > is row locked; that can e.g. happen when foreign keys are used."
> > >
> > > IIUC, this case only occurs when using the new-in-9.3 types of
> > > nonexclusive row locks. I'm willing to bet that the number of
> > > applications using those is negligible; so I think it's all right to not
> > > mention that case explicitly, as long as the wording doesn't say that
> > > foreign keys are the *only* cause (which I didn't).
> >
> > I actually think the issue could also occur with row locks of other
> > severities (is that the correct term?). Alvaro probably knows better,
> > but if I see correctly it's also triggerable if a backend waits for an
> > updating transaction to finish and follow_updates = true is passed to
> > heap_lock_tuple(). Which e.g. nodeLockRows.c does...
>
> Uhm. But at the bottom of that block, right above the "failed:" label
> (heapam.c line 4527 in current master), we recheck the tuple for
> "locked-only-ness"; and fail the whole operation by returning
> HeapTupleUpdated, if it's not locked-only, no? Which would cause
> ExecLockRows to grab the next version via EvalPlanQualFetch.
> Essentially that check is a lock-conflict test, and the only thing that
> does not conflict with an update is a FOR KEY SHARE lock.

What I was thinking of is the case where heap_lock_tuple() notices it
needs to sleep and then in the if (require_sleep) block does a
lock_updated_tuple(). If the updating transaction aborts while waiting
lock_updated_tuple_rec() will issue a XLOG_HEAP2_LOCK_UPDATED for that
row and then return MayBeUpdated. Which will make heap_lock_tuple()
successfully lock the row, thereby resetting t_ctid during replay. What
I missed is that case resetting the ctid chain is perfectly fine, since
the pointed to tuple is actually dead. I was just confused by the fact
that we do actually issue a XLOG_HEAP2_LOCK_UPDATED for a dead row.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2014-03-17 20:56:10 Re: bpchar functinos
Previous Message Merlin Moncure 2014-03-17 20:32:34 Re: Planner hints in Postgresql