From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5915: OldSerXidAdd inflates pg_serial too much
Date: Fri, 04 Mar 2011 15:16:51 -0600
Message-ID: <4D710263020000250003B4CD@gw.wicourts.gov> (raw)
In-Reply-To: <4D714A6B.3030506@enterprisedb.com>
References: <201103041241.p24CfDZV063217@wwwmaster.postgresql.org>
<4D70E897020000250003B4B8@gw.wicourts.gov>
<4D714A6B.3030506@enterprisedb.com>
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote:
> I wonder if we should move the responsibility of truncating the
> SLRU to checkpoint. At the moment, it's done in
> OldSerXidSetActiveSerXmin(), while the callers are holding
> SerializableXactHashLock in exclusive mode. While it'll probably
> go quickly in practice, it still seems like there's a risk of
> stalling all new transactions for a few seconds while that
> happens.
I don't think it can stall new transactions unless they are
DEFERRABLE, but it might stall the COMMIT of the oldest serializable
transaction -- if I'm thinking it through correctly. (If not, I
have another energy drink I can crack open.)
Here's my thinking:
The call in RegisterSerializableTransactionInt() to
OldSerXidSetActiveSerXmin() only happens if there are no active
serializable transactions, so it can't fall into the SLRU truncation
code (I think). I'm not worried about
predicatelock_twophase_recover() because it will only call the
function during startup with no transactions active, so it can't hit
the cleanup code. That leaves SetNewSxactGlobalXmin(), which is
only called from ReleasePredicateLocks(), and only when the last
transaction with the low xmin is being cleaned up. Now, that's only
called around completion of a transaction except when starting a
SERIALIZABLE READ ONLY DEFERRABLE transaction; and if you have
explicitly requested a DEFERRABLE transaction you presumably won't
be astonished by a delay in its startup.
So, I'm not arguing that we shouldn't move the truncation to
checkpoint time, but I think what we're protecting against is disk
I/O at COMMIT time, not transaction startup. Presumably disk I/O at
that point would be less surprising, although perhaps the fact that
it can happen on a read only transaction might surprise someone. Of
course, moving any possible delay from this to a background process
seems like a good thing in general; I just don't know whether it's
worth doing right now, versus adding to a list of possible
enhancements. If you're confident it's safe enough, I'm game.
-Kevin
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-bugs@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, heikki.linnakangas@enterprisedb.com, yamt@mwd.biglobe.ne.jp
Subject: Re: BUG #5915: OldSerXidAdd inflates pg_serial too much
In-Reply-To: <4D710263020000250003B4CD@gw.wicourts.gov>
References: <201103041241.p24CfDZV063217@wwwmaster.postgresql.org> <4D70E897020000250003B4B8@gw.wicourts.gov> <4D714A6B.3030506@enterprisedb.com> <4D710263020000250003B4CD@gw.wicourts.gov>
* 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