Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBwDa-0003uv-1F for pgsql-bugs@postgresql.org; Wed, 12 Sep 2012 23:19:38 +0000 Received: from mail-ob0-f174.google.com ([209.85.214.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBwDX-0004pD-Aj for pgsql-bugs@postgresql.org; Wed, 12 Sep 2012 23:19:37 +0000 Received: by obbuo13 with SMTP id uo13so3540023obb.19 for ; Wed, 12 Sep 2012 16:19:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:from:to:in-reply-to:references:content-type:date:message-id :mime-version:x-mailer:content-transfer-encoding:x-gm-message-state; bh=942dggxHAf381cCgd0lMM0OQh2MN/N1OQ3G7rYG36Rs=; b=pUgtsGx3huNtPZSkz4g4Oc/rtNk4cJxjKQ2w/cH60l3gMsKd8NjA3QzGACGDB3jWUI oXq54m7lUZSB+F8V68BChEkqZpgxfv+P/0wV4U6NGkZSkXT9DHQUVDJGcBxryNT1bFoy wrC7G5ZAJSiJ6uE6IT3t2PlF5AH7+dpI0vQrB7Y/lX5akEqNNPpHMdMHQ9TLF752/6Gd xFhfWjPxZdw8/uwjAtHAg1Lj16xMXRQiV1tjdXq6L6UlPJ4QCPuN3XlP5WyWjetcBi4o sLq23d9RIdHWTJdoIiyHoOO6CXhxWKE2mjmwxbMah7ln+XlmDJDh6fwqjUdM2uFiW0+T Y0Zw== Received: by 10.182.131.37 with SMTP id oj5mr77786obb.54.1347491973285; Wed, 12 Sep 2012 16:19:33 -0700 (PDT) Received: from ?IPv6:::1? ([2600:3c01::f03c:91ff:fe93:2ae4]) by mx.google.com with ESMTPS id bp7sm21714007obc.12.2012.09.12.16.19.30 (version=SSLv3 cipher=OTHER); Wed, 12 Sep 2012 16:19:31 -0700 (PDT) Subject: Re: Probable bug with CreateFakeRelcacheEntry (now with reproducible test case) From: Jeff Davis To: pgsql-bugs@postgresql.org In-Reply-To: <1347327239.4161.20.camel@sussancws0025> References: <1347327239.4161.20.camel@sussancws0025> Content-Type: text/plain; charset="ISO-8859-1" Date: Wed, 12 Sep 2012 16:19:29 -0700 Message-ID: <1347491969.4161.63.camel@sussancws0025> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmnfUDBpoMQTvLOPQIb4WGQVk393VBPWGBqtINulu8w6d70NXv7p5qwP6idoKt2zCDWNxBJ X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201209/108 X-Sequence-Number: 34103 Indeed, this is a nasty bug that leads to data corruption. The following sequence results in corruption of the visibility map, but I believe it can be shown to cause problems for a btree or GIN index as well. So it's recoverable if you do a VACUUM or a reindex. drop table foo; create table foo(i int); create index foo_idx on foo(i); insert into foo values(1); vacuum foo; checkpoint; insert into foo values(2); -- Send a SIGQUIT to the postmaster, and restart it. -- Now the buffer for the VM is in shared memory without BM_PERMANENT. -- VM block comes from backup block which still has VM bit set, but wal -- record for insert (2) unsets it in memory. delete from foo where i = 2; -- This checkpoint will *not* write out the buffer because it's not -- BM_PERMANENT. Therefore, it remains the same on disk, with the VM -- bit set. checkpoint; -- Send a SIGQUIT to the postmaster and restart. WAL records prior to -- that last checkpoint aren't replayed, so VM bit is still set. set enable_seqscan=false; select * from foo where i = 2; vacuum foo; WARNING: page is not marked all-visible but visibility map bit is set in relation "foo" page 0 VACUUM select * from foo; i --- 1 (1 row) This bug seems particularly troublesome because the right fix would be to include the relpersistence in the WAL records that need it. But that can't be backported (right?). The problem might not be a live problem before 7e4911b2ae33acff7b85234b91372133ec6df9d4, because that bug was hiding this one. Regards, Jeff Davis