Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D01F41337BD0 for ; Fri, 4 Mar 2011 12:00:07 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 73887-06 for ; Fri, 4 Mar 2011 15:59:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og126.obsmtp.com (exprod7og126.obsmtp.com [64.18.2.206]) by mail.postgresql.org (Postfix) with ESMTP id A41021337BC8 for ; Fri, 4 Mar 2011 11:59:58 -0400 (AST) Received: from source ([209.85.161.50]) (using TLSv1) by exprod7ob126.postini.com ([64.18.6.12]) with SMTP ID DSNKTXEMfZ/tTXG3ygWkiqIdHFnz2f8rmtWO@postini.com; Fri, 04 Mar 2011 07:59:58 PST Received: by mail-fx0-f50.google.com with SMTP id 18so2813541fxm.37 for ; Fri, 04 Mar 2011 07:59:57 -0800 (PST) Received: by 10.223.77.19 with SMTP id e19mr1004025fak.36.1299253959891; Fri, 04 Mar 2011 07:52:39 -0800 (PST) Received: from [85.76.25.115] (YZKMMMCDXV.gprs.sl-laajakaista.fi [85.76.25.115]) by mx.google.com with ESMTPS id n1sm1229320fam.40.2011.03.04.07.52.34 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Mar 2011 07:52:39 -0800 (PST) Message-ID: <4D710ABD.5090103@enterprisedb.com> Date: Fri, 04 Mar 2011 17:52:29 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20101226 Icedove/3.0.11 MIME-Version: 1.0 To: daveg CC: PostgreSQL-development Subject: Re: Re: PD_ALL_VISIBLE flag was incorrectly set happend during repeatable vacuum References: <4D2D6A56.9060808@enterprisedb.com> <20110228212832.GH26397@sonic.net> <1B3CCBDD-4AC6-404A-9E26-DB4CA2554228@endpoint.com> <20110303071208.GA4053@sonic.net> <4D6F4E5D.6080507@enterprisedb.com> <20110304090031.GE4053@sonic.net> In-Reply-To: <20110304090031.GE4053@sonic.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 201103/314 X-Sequence-Number: 183564 On 04.03.2011 11:00, daveg wrote: > Thanks, I've applied both patches to one host. I'll probably have to back > down on the debugging logging soon, as the output is pretty voluminious, > it is producing 100MB of message log every few minutes. I'll try Merlins > patch to get the case setting the bit first though. > > Anyway, here is a snippit of log with the setting and unsetting of the > bit on one page. Unfortunately, we don't know which of a dozen odd databases > the page belongs to, but the timestamps are so close it seems likely to be > the same one. I've added dbname to the patch and will get that next time > I can switch binaries. > > 2011-03-03 23:28:34.170 PST 2039 WARNING: debugging: setting PD_ALL_VISIBLE in relation "pg_statistic" on page 5963 (OldestXmin 331848998) > ... > /cv/logs/production_03-20110303_232519.log.gz:2011-03-03 23:29:34.194 PST 2115 WARNING: PD_ALL_VISIBLE flag was incorrectly set in relation "pg_statistic" page 5963 (OldestXmin 331677178) > ... > 2011-03-03 23:42:38.323 PST 2808 WARNING: debugging: setting PD_ALL_VISIBLE in relation "pg_attribute" on page 5963 (OldestXmin 331677178) Hmm, if these all came from the same database, then it looks OldestXmin has moved backwards. That would explain the warnings. First one vacuum determines that all the tuples are visible to everyone and sets the flag. Then another vacuum runs with an older OldestXmin, and determines that there's a tuple on the page with an xmin that is not yet visible to everyone, hence it thinks that the flag should not have been set yet. Looking at the code, I don't see how that situation could arise, though. The value calculated by GetOldestXmin() should never move backwards. And GetOldestXmin() is called in lazy_vacuum_rel(), after it has acquired a lock on the table, which should protect from a race condition where two vacuums could run on the table one after another, in a way where the later vacuum runs with an OldestXmin calculated before the first vacuum. Hmm, fiddling with vacuum_defer_cleanup_age on the fly could cause that, though. You don't do that, do you? > Also, I've attached the relevent page image. Thanks. There seems to be two tuples on the page, both of were HOT updated at some point, but now there's only one version of each left: postgres=# SELECT lp, lp_off, lp_flags, lp_len, t_xmin, t_xmax, t_ctid, t_infomask, t_infomask2, t_hoff FROM heap_page_items(loread(lo_open(29924, 262144), 8192)) WHERE lp_flags <> 0; lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_ctid | t_infomask | t_infomask2 | t_hoff ----+--------+----------+--------+-----------+--------+----------+------------+-------------+-------- 1 | 7608 | 1 | 580 | 331250141 | 0 | (5963,1) | 10499 | -32747 | 32 3 | 1 | 2 | 0 | | | | | | 4 | 7528 | 1 | 76 | 331735553 | 0 | (5963,4) | 10497 | -32747 | 32 19 | 4 | 2 | 0 | | | | | | (4 rows) Deciphering those infomasks, the first tuple at lp 1 has these flags set: HEAP_UPDATED | HEAP_XMAX_INVALID | HEAP_XMIN_COMMITTED | HEAP_HASNULL | HEAP_HASVARWIDTH And the 2nd one at lp 4: HEAP_UPDATED | HEAP_XMAX_INVALID | HEAP_XMIN_COMMITTED | HEAP_HASNULL So, both of those tuples are live. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com