Re: mvcc catalo gsnapshots and TopTransactionContext

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: mvcc catalo gsnapshots and TopTransactionContext
Date: 2013-07-12 09:42:23
Message-ID: 20130712094223.GK27898@alap2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2013-07-11 11:53:57 -0700, Jeff Davis wrote:
> On Thu, 2013-07-11 at 10:28 +0200, Andres Freund wrote:
> > There doesn't seem be an explicitly stated rule that we cannot use the
> > syscaches outside of a transaction - but effectively that's required
> > atm.
>
> Aren't there other things that already required that before the MVCC
> catalog snapshot patch went in? For instance, if you get a syscache
> miss, you have to load from the catalogs, meaning you need to acquire a
> lock.

There are. Several. I am blaming it on conference induced haze. Or such.

On 2013-07-11 15:09:45 -0400, Tom Lane wrote:
> It never has been, and never will be, allowed to call the catcache code
> without being in a transaction. What do you think will happen if the
> requested row isn't in cache? A table access, that's what, and that
> absolutely requires being in a transaction.

Makes sense. I was confused because I thought I saw a
get_database_name() and other users outside of a transaction but that
turned out not looking closely enough.

I'd like to add an Assert like in the attached patch making sure we're
in a transaction. Otherwise it's far too easy not to hit an error during
development because everything is cached - and syscache usage isn't
always obvious from the outside to the naive or the tired.

Greetings,

Andres Freund

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

Attachment Content-Type Size
assert-transaction-state-in-searchcatcache.patch text/x-patch 679 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2013-07-12 10:30:20 Re: docbook-xsl version for release builds
Previous Message Hitoshi Harada 2013-07-12 08:11:19 Re: refresh materialized view concurrently