pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: yamt@mwd.biglobe.ne.jp
Cc: pgsql-bugs@postgresql.org
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Subject: Re: BUG #6218: TRAP: FailedAssertion( "!(owner->nsnapshots == 0)", File: "resowner.c", Line: 365)
Date: Mon, 26 Sep 2011 12:26:37 -0400
Message-ID: <8244.1317054397@sss.pgh.pa.us> (raw)
In-Reply-To: <20110926100653.4D3BC14A143@mail.netbsd.org>
References: <5291.1316980809@sss.pgh.pa.us>
	<20110926100653.4D3BC14A143@mail.netbsd.org>

yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) writes:
>> Maybe, but I'd still like to see a test case, because I can't reproduce
>> any such problem by preparing ROLLBACK in an aborted transaction.

> reading GetTransactionSnapshot, it seems that the problem happens
> only with IsolationUsesXactSnapshot() true.

Hmm.  I'm inclined to think that this demonstrates a bug in snapshot
management, not so much in plancache.  We have plancache doing

		PushActiveSnapshot(GetTransactionSnapshot());

and then later

		PopActiveSnapshot();

and at this point surely it is not plancache's fault if there is any
remaining refcount for the snapshot.  There is, though, because
GetTransactionSnapshot saved a refcount in TopTransactionResourceOwner.
I think it's snapmgr.c's responsibility to make sure that that's cleaned
up, and it's not doing so.

The place where that refcount normally gets dropped is
AtEarlyCommit_Snapshot, but that isn't going to be called at all in
aborted-transaction cleanup.  Worse, if we just transposed it over to be
called in a place in AbortTransaction comparable to where it's called
during commit, that still wouldn't fix the problem, because when the
ROLLBACK happens, we've already aborted the transaction.

I think that AtEarlyCommit_Snapshot is misdesigned, and that far from
being done "early" in commit/abort, it needs to be done "late", like
somewhere not very long before the
ResourceOwnerDelete(TopTransactionResourceOwner) calls.  There is no
very good reason to think that someone might not ask for a snapshot
during commit processing.

Alvaro, do you happen to remember why this got designed as an "early"
transaction shutdown action, rather than delaying it as long as
possible?

			regards, tom lane



view thread (11+ messages)  latest in thread

Message-ID: <8244.1317054397@sss.pgh.pa.us>
Permalink:  ../8244.1317054397@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8244.1317054397@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, yamt@mwd.biglobe.ne.jp, alvherre@commandprompt.com
  Subject: Re: BUG #6218: TRAP: FailedAssertion( "!(owner->nsnapshots == 0)", File: "resowner.c", Line: 365)
  In-Reply-To: <8244.1317054397@sss.pgh.pa.us>
  References: <5291.1316980809@sss.pgh.pa.us> <20110926100653.4D3BC14A143@mail.netbsd.org> <8244.1317054397@sss.pgh.pa.us>

* 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