Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZHDgY-0004ro-Dq for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jul 2015 16:12:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZHDgY-0002Cc-01 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jul 2015 16:12:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZHDfG-0000kb-RW for pgsql-hackers@postgresql.org; Mon, 20 Jul 2015 16:11:38 +0000 Received: from smtp-auth.no-ip.com ([8.23.224.61] helo=out.smtp-auth.no-ip.com) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZHDfB-000196-Hj for pgsql-hackers@postgresql.org; Mon, 20 Jul 2015 16:11:38 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [89.176.99.192]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 0C2AE40084E; Mon, 20 Jul 2015 09:11:27 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id DD83936F0; Mon, 20 Jul 2015 20:11:24 +0400 (SAMT) Date: Mon, 20 Jul 2015 18:11:24 +0200 From: Alvaro Herrera To: Heikki Linnakangas Cc: pgsql-hackers Subject: Re: All-zero page in GIN index causes assertion failure Message-ID: <20150720161124.GR2301@postgresql.org> References: <55ACADCD.6020206@iki.fi> <55AD0266.4050300@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <55AD0266.4050300@iki.fi> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Heikki Linnakangas wrote: > Looking closer, heap vacuum does a similar thing, but there are two > mitigating factors that make it safe in practice, I think: > > 1. An empty heap page is all-zeroes except for the small page header in the > beginning of the page. For a torn page to matter, the page would need to be > torn in the header, but we rely elsewhere (control file) anyway that a > 512-byte sector update is atomic, so that shouldn't happen. Note that this > hinges on the fact that there is no special area on heap pages, so you > cannot rely on this for index pages. > > 2. The redo of the first insert/update on a heap page will always > re-initialize the page, even when full-page-writes are disabled. This is the > XLOG_HEAP_INIT_PAGE optimization. So it's not just an optimization, it's > required for correctness. Hmm, I guess this is a case of an optimization hiding a bug :-( I mean, if we didn't have that, we would have noticed this a lot sooner, I imagine. > BRIN update is not quite right, however. brin_getinsertbuffer() can > initialize a page, but the caller might bail out without using the page and > WAL-logging the change. If that happens, the next update that uses the same > page will WAL-log the change but it will not use the XLOG_BRIN_INIT_PAGE > option, and redo will not initialize the page. Redo will fail. Hmm, interesting. > BTW, shouldn't there be a step in BRIN vacuum that scans all the BRIN pages? > If an empty page is missing from the FSM for any reason, there's nothing to > add it there. Probably, yeah, makes sense. If you recall, the original design I proposed had a scan of the whole index (though for other reasons I am thankful we got rid of that). > This is all very subtle. No kidding ... -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers