Re: pgsql: Assert(IsTransactionState()) in RelationIdGetRelation().

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Assert(IsTransactionState()) in RelationIdGetRelation().
Date: 2014-02-11 20:15:26
Message-ID: 20140211201526.GP15246@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On 2014-02-11 14:45:00 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On 2014-02-06 16:28:23 +0000, Tom Lane wrote:
> >> Assert(IsTransactionState()) in RelationIdGetRelation().
>
> > Hm, I am not sure if it works this way. In a patched postgres I just
> > got:
> > #2 0x00000000008b4b27 in ExceptionalCondition (conditionName=0xa90a78 "!(IsTransactionState())", errorType=0xa90708 "FailedAssertion",
> > fileName=0xa905c8 "/home/andres/src/postgresql/src/backend/utils/cache/relcache.c", lineNumber=1622)
> > at /home/andres/src/postgresql/src/backend/utils/error/assert.c:54
> > #3 0x00000000008a3fd6 in RelationIdGetRelation (relationId=1259) at /home/andres/src/postgresql/src/backend/utils/cache/relcache.c:1622
> > #4 0x00000000004a25ea in relation_open (relationId=1259, lockmode=1) at /home/andres/src/postgresql/src/backend/access/heap/heapam.c:1038
> > #5 0x00000000004a2898 in heap_open (relationId=1259, lockmode=1) at /home/andres/src/postgresql/src/backend/access/heap/heapam.c:1201
> > #6 0x00000000008a10ba in ScanPgRelation (targetRelId=2693, indexOK=1 '\001', suspend_snap=1 '\001')
> > at /home/andres/src/postgresql/src/backend/utils/cache/relcache.c:308
> > #7 0x00000000008a268c in RelationInitPhysicalAddr (relation=0x7fac2a842658)
> > at /home/andres/src/postgresql/src/backend/utils/cache/relcache.c:1019
>
> Um ... what is RelationInitPhysicalAddr doing calling ScanPgRelation?
> That function shouldn't be doing any new catalog access.

Argh, sorry, didn't think far enough. Yes, that's specific to the branch
I am testing, and the after your recent changes there shouldn't be any
catalog accesses in TRANS_START due to invalidations in master. This
just needed to be adapted to that (i.e the same if (IsTransactionState())
added).

The reason we're doing catalog accesses there is that when decoding the
WAL's contents we want a relation descriptor that looks like one would
have when the WAL record was created, but for catalog tables we want the
the relfilenode to point to the current relfilenode (normal relations
are never accessed). So we use a "historical" snapshot to build the
relcache entry and an up2date one to lookup the
relfilenode.
RelationInitPhysicalAddr() seems like the correct place to deal with
that since nothing else needs to know.

Greetings,

Andres Freund

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

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-02-12 16:22:29 pgsql: Tweak position of $(DLL_DEFFILE) in shared-library link commands
Previous Message Tom Lane 2014-02-11 19:45:00 Re: pgsql: Assert(IsTransactionState()) in RelationIdGetRelation().