pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Maxim Boguk <maxim.boguk@gmail.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: Jeremy Finzel <finzelj@gmail.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: found xmin from before relfrozenxid on pg_catalog.pg_authid
Date: Thu, 24 May 2018 16:46:24 -0400
Message-ID: <20180524204624.7ayv3bi3gsyagmsh@alvherre.pgsql> (raw)
In-Reply-To: <20180524203054.k7lnxjbe2unfvsgm@alap3.anarazel.de>

On 2018-May-24, Andres Freund wrote:

> On 2018-05-24 13:08:53 -0400, Alvaro Herrera wrote:
> > Hmm .. surely

> >  	xid = HeapTupleHeaderGetXmin(tuple);
> >  	xmin_frozen = ((xid == FrozenTransactionId) ||
> >  				   HeapTupleHeaderXminFrozen(tuple));
> > -	if (TransactionIdIsNormal(xid))
> > +	if (!xmin_frozen && TransactionIdIsNormal(xid))

> I don't think that's necesary - HeapTupleHeaderGetXmin() returns
> FrozenTransactionId if the tuple is frozen (note the
> HeapTupleHeaderXminFrozen() within).

Ah, yeah ... I probably thought about this when writing it and removed
it for that reason.

BTW I think the definition of HeapTupleHeaderXminFrozen is seriously
confusing, by failing to return true if the xmin is numerically
FrozenXid (which it'll be if the database was pg_upgraded).  I wonder
about this one in HeapTupleSatisfiesMVCC:

	else
	{
		/* xmin is committed, but maybe not according to our snapshot */
		if (!HeapTupleHeaderXminFrozen(tuple) &&
			XidInMVCCSnapshot(HeapTupleHeaderGetRawXmin(tuple), snapshot))
			return false;		/* treat as still in progress */
	}

I think this is not a bug only because XidInMVCCSnapshot does this

	/* Any xid < xmin is not in-progress */
	if (TransactionIdPrecedes(xid, snapshot->xmin))
		return false;

which makes it return false for FrozenXid, but seems more of an accident
than explicitly designed.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (78+ messages)  latest in thread

Message-ID: <20180524204624.7ayv3bi3gsyagmsh@alvherre.pgsql>
Permalink:  ../20180524204624.7ayv3bi3gsyagmsh@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180524204624.7ayv3bi3gsyagmsh@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alvherre@2ndquadrant.com, andres@anarazel.de, maxim.boguk@gmail.com, pg@bowt.ie, finzelj@gmail.com
  Subject: Re: found xmin from before relfrozenxid on pg_catalog.pg_authid
  In-Reply-To: <20180524204624.7ayv3bi3gsyagmsh@alvherre.pgsql>
  References: <20180524203054.k7lnxjbe2unfvsgm@alap3.anarazel.de> <20180524204624.7ayv3bi3gsyagmsh@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox