Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2C8CD133798E for ; Sat, 12 Feb 2011 03:08:33 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 85185-04 for ; Sat, 12 Feb 2011 07:08:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11]) by mail.postgresql.org (Postfix) with ESMTP id DCCDC133616B for ; Sat, 12 Feb 2011 03:08:24 -0400 (AST) Received: by mail.netbsd.org (Postfix, from userid 1270) id 46BE319D15D; Sat, 12 Feb 2011 07:08:22 +0000 (UTC) To: Kevin.Grittner@wicourts.gov Cc: pgsql-hackers@postgresql.org Subject: Re: SSI bug? In-Reply-To: Your message of "Fri, 11 Feb 2011 09:48:18 -0600" <4D5505E2020000250003A83C@gw.wicourts.gov> References: <4D5505E2020000250003A83C@gw.wicourts.gov> X-Mailer: Cue version 0.8 (100217-1432/takashi) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-20110212160545-1048700" Message-Id: <20110212070822.46BE319D15D@mail.netbsd.org> Date: Sat, 12 Feb 2011 07:08:21 +0000 (UTC) From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.2 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201102/1146 X-Sequence-Number: 181935 --Boundary-20110212160545-1048700 Content-Type: Text/Plain; charset=us-ascii hi, > YAMAMOTO Takashi wrote: > >> it seems that PredicateLockTupleRowVersionLink sometimes create >> a loop of targets (it founds an existing 'newtarget' whose >> nextVersionOfRow chain points to the 'oldtarget') and it later >> causes CheckTargetForConflictsIn loop forever. > > Is this a hypothetical risk based on looking at the code, or have > you seen this actually happen? Either way, could you provide more > details? (A reproducible test case would be ideal.) i have seen this actually happen. i've confirmed the creation of the loop with the attached patch. it's easily reproducable with my application. i can provide the full source code of my application if you want. (but it isn't easy to run unless you are familiar with the recent version of NetBSD) i haven't found a smaller reproducible test case yet. YAMAMOTO Takashi > > This being the newest part of the code, I'll grant that it is the > most likely to have an unidentified bug; but given that the pointers > are from one predicate lock target structure identified by a tuple > ID to one identified by the tuple ID of the next version of the row, > it isn't obvious to me how a cycle could develop. > > -Kevin --Boundary-20110212160545-1048700 Content-Type: Text/Plain; charset=us-ascii Content-Disposition: attachment; filename="a.diff" diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 722d0f8..3e1a3e2 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -2350,7 +2350,25 @@ PredicateLockTupleRowVersionLink(const Relation relation, newtarget->nextVersionOfRow = NULL; } else + { Assert(newtarget->priorVersionOfRow == NULL); +#if 0 + Assert(newtarget->nextVersionOfRow == NULL); +#endif + if (newtarget->nextVersionOfRow != NULL) { + PREDICATELOCKTARGET *t; + + elog(WARNING, "new %p has next %p\n", + newtarget, newtarget->nextVersionOfRow); + for (t = newtarget->nextVersionOfRow; t != NULL; + t = t->nextVersionOfRow) { + if (oldtarget != t) { + elog(WARNING, "creating a loop new=%p old=%p\n", + newtarget, oldtarget); + } + } + } + } newtarget->priorVersionOfRow = oldtarget; oldtarget->nextVersionOfRow = newtarget; --Boundary-20110212160545-1048700--