Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 000B818E38DA for ; Thu, 12 Jan 2012 14:19:31 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RlPFK-0003dP-Ch for pgsql-bugs@postgresql.org; Thu, 12 Jan 2012 18:19:31 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q0CIJETR024905; Thu, 12 Jan 2012 13:19:14 -0500 (EST) To: Maxim Boguk cc: Alvaro Herrera , Pg Bugs Subject: Re: BUG #6393: cluster sometime fail under heavy concurrent write load In-reply-to: <23799.1326389068@sss.pgh.pa.us> References: <1326295419-sup-3436@alvh.no-ip.org> <23799.1326389068@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 12 Jan 2012 12:24:28 -0500" Date: Thu, 12 Jan 2012 13:19:14 -0500 Message-ID: <24904.1326392354@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/106 X-Sequence-Number: 32173 I wrote: > Yes, this is a consequence of commit > 44b6d53b467bfe848c34c7a8a174779bb2f43c39, which tried to preserve toast > OIDs when doing a table rewrite. The problem is that CLUSTER needs to > copy both the old and new versions of an updated row, since the old one > is only "recently dead", and both of those versions are pointing at the > same TOAST item because the update didn't affect the toasted column. > So when we save those versions into the new table separately, we try to > write the same TOAST item twice. BTW, it strikes me that the preceding implementation had its own bug in this area: in the same situation of having to copy multiple versions of a row, it would create independent copies of the referenced TOAST value. Not only is this space-wasteful, but the copies attached to the already-dead row versions would never be reclaimed, at least not short of another CLUSTER, because they would be inserted into the toast table as live not deleted rows. So preserving toast item OIDs and relying on them for duplicate detection actually will improve matters in a way unrelated to the original purpose of commit 44b6d53b467bfe848c34c7a8a174779bb2f43c39. regards, tom lane