Re: WIP: getting rid of the pg_database flat file

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: WIP: getting rid of the pg_database flat file
Date: 2009-08-12 18:21:49
Message-ID: 22032.1250101309@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> No, that's for the workers. The launcher needs all the entries anyway.
> (I'm assuming it will be able to check visibility of tuples, correct?
> Hmm, it will need to run transactions in order to do that ...)

No, you don't need to be in a transaction to check visibility.
flatfiles.c is already doing that without being in a transaction,
in some cases. What you need a transaction for is to be able to
hold AccessShareLock on the table you're scanning. For pg_database
it's not possible for any schema changes (like relfilenode changes)
to happen anyway. But it is possible for vacuum to try to truncate
away empty end pages, which could result in a failure of a concurrent
heapscan without a lock. The code in flatfiles.c is safe because it's
only doing that during the startup process when nobody else could be
running vacuum, but I don't suppose we can assume that for the AV
launcher.

I just noticed that we are depending on flatfiles.c to do a couple of
things other than generate the flat files. In particular, we piggyback
on its scan of pg_database to produce the initial transaction ID wrap
limit value, and we rely on it to find all the databases that
RelationCacheInitFileRemove needs to be called for. I had been thinking
of replacing the latter bit with a directory search, but I don't see how
to get rid of scanning pg_database for the wrap limit setting. So it
seems like there is still going to need to be a linear scan of
pg_database during system startup. Annoying ...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zdenek Kotala 2009-08-12 19:59:31 Re: compilation with libeditpreferred is broken
Previous Message Kevin Grittner 2009-08-12 18:17:05 Re: Why is vacuum_freeze_min_age 100m?