Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 684071337B80 for ; Wed, 12 Jan 2011 04:46:34 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 12739-02; Wed, 12 Jan 2011 08:46:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og127.obsmtp.com (exprod7og127.obsmtp.com [64.18.2.210]) by mail.postgresql.org (Postfix) with SMTP id 999C61337BAE; Wed, 12 Jan 2011 04:46:25 -0400 (AST) Received: from source ([209.85.215.47]) by exprod7ob127.postini.com ([64.18.6.12]) with SMTP ID DSNKTS1qYOz0ObNB7oegMTjsXYgtsYi5fyuj@postini.com; Wed, 12 Jan 2011 00:46:26 PST Received: by ewy28 with SMTP id 28so111705ewy.6 for ; Wed, 12 Jan 2011 00:46:20 -0800 (PST) Received: by 10.213.17.197 with SMTP id t5mr3673802eba.64.1294821978593; Wed, 12 Jan 2011 00:46:18 -0800 (PST) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id v59sm326238eeh.21.2011.01.12.00.46.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 12 Jan 2011 00:46:17 -0800 (PST) Message-ID: <4D2D6A56.9060808@enterprisedb.com> Date: Wed, 12 Jan 2011 10:46:14 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.15) Gecko/20101030 Icedove/3.0.10 MIME-Version: 1.0 To: Maxim Boguk CC: Fujii Masao , pgsql-admin@postgresql.org, PostgreSQL-development Subject: Re: [HACKERS] Re: PD_ALL_VISIBLE flag was incorrectly set happend during repeatable vacuum References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------080500090308060107000509" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.2 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201101/56 X-Sequence-Number: 36496 This is a multi-part message in MIME format. --------------080500090308060107000509 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 12.01.2011 06:21, Fujii Masao wrote: > On Sat, Dec 25, 2010 at 2:09 PM, Maxim Boguk wrote: >> While I trying create reproducible test case for BUG #5798 I >> encountered very strange effect on two of my servers (both servers >> have same hardware platform/OS (freebsd 7.2) and PostgreSQL 8.4.4). >> >> Very simple test table created as: >> CREATE TABLE test (id integer); >> INSERT INTO test select generate_series(0,10000); >> >> And I trying repeateble vacuum of that table with script: >> perl -e "foreach (1..100000) {system \"psql -d test -h -c 'vacuum test'\";}" >> >> And once per like an minute (really random intervals can be 5 minutes >> without problems can be 3 vacuum in row show same error) I getting >> next errors: >> WARNING: PD_ALL_VISIBLE flag was incorrectly set in relation "test" page 1 >> ... >> WARNING: PD_ALL_VISIBLE flag was incorrectly set in relation "test" >> page 30 for all pages of the relation. Oh, interesting. This is the first time anyone can reliably reproducible that. I can't reproduce that on my laptop with that script, though, so I'm going to need your help to debug this. Can you compile PostgreSQL with the attached patch, and rerun the test? It will dump the pages with incorrectly set flags to files in /tmp/, and adds a bit more detail in the WARNING. Please run the test until you get those warnings, and tar up the the created "/tmp/pageimage*" files, and post them along with the warning generated. We'll likely need to go back and forth a few times with various debugging patches until we get to the heart of this.. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com --------------080500090308060107000509 Content-Type: text/x-diff; name="debug-pd_all_visible-1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="debug-pd_all_visible-1.patch" diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 67e0be9..0e88aa5 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -48,6 +48,7 @@ #include "pgstat.h" #include "postmaster/autovacuum.h" #include "storage/bufmgr.h" +#include "storage/fd.h" #include "storage/freespace.h" #include "storage/lmgr.h" #include "utils/inval.h" @@ -668,13 +669,26 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, /* Update the all-visible flag on the page */ if (!PageIsAllVisible(page) && all_visible) { + elog(WARNING, "debugging: setting PD_ALL_VISIBLE in relation \"%s\" on page %u (OldestXmin %u)", relname, blkno, OldestXmin); PageSetAllVisible(page); SetBufferCommitInfoNeedsSave(buf); } else if (PageIsAllVisible(page) && !all_visible) { - elog(WARNING, "PD_ALL_VISIBLE flag was incorrectly set in relation \"%s\" page %u", - relname, blkno); + elog(WARNING, "PD_ALL_VISIBLE flag was incorrectly set in relation \"%s\" page %u (OldestXmin %u)", + relname, blkno, OldestXmin); + { + char fname[MAXPGPATH]; + FILE *fp; + + /* dump the raw page to a file */ + snprintf(fname, sizeof(fname), "/tmp/pageimage_%s_%d", + relname, blkno); + fp = AllocateFile(fname, "wb"); + fwrite(page, 1, BLCKSZ, fp); + FreeFile(fp); + + } PageClearAllVisible(page); SetBufferCommitInfoNeedsSave(buf); --------------080500090308060107000509--