Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amTYW-0002Ry-4c for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Apr 2016 21:58:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1amTYV-0000ws-N0 for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Apr 2016 21:58:07 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1amTYT-0000wc-9S for pgsql-hackers@postgresql.org; Sat, 02 Apr 2016 21:58:06 +0000 Received: from smtp-auth.no-ip.com ([8.23.224.61] helo=out.smtp-auth.no-ip.com) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1amTYK-0006Zj-Jm for pgsql-hackers@postgresql.org; Sat, 02 Apr 2016 21:57:58 +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 [200.126.117.252]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 3640F40097E; Sat, 2 Apr 2016 14:57:51 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 7DEAA3DA0; Sat, 2 Apr 2016 18:57:48 -0300 (CLT) Date: Sat, 2 Apr 2016 18:57:48 -0300 From: Alvaro Herrera To: Bernd Helmle Cc: pgsql-hackers@postgresql.org Subject: Re: standalone backend PANICs during recovery Message-ID: <20160402215748.GA136801@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <00F0B2CEF6D0CEF8A90119D4@eje.credativ.lan> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.1 (-) 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 Bernd Helmle wrote: > While investigating a problem on a streaming hot standby instance at a > customer site, i got the following when using a standalone backend: > > PANIC: btree_xlog_delete_get_latestRemovedXid: cannot operate with > inconsistent data > CONTEXT: xlog redo delete: index 1663/65588/65625; iblk 11, heap > 1663/65588/65613; > > The responsible PANIC is triggered here: > > src/backend/access/nbtree/nbtxlog.c:555 > > btree_xlog_delete_get_latestRemovedXid(XLogReaderState *record) This PANIC was introduced in the commit below. AFAICS your proposed patch and rationale are correct. commit f786e91a75b2f64527dcf321e754b6448fcad7fe Author: Tom Lane AuthorDate: Fri Aug 3 15:41:18 2012 -0400 CommitDate: Fri Aug 3 15:41:18 2012 -0400 Improve underdocumented btree_xlog_delete_get_latestRemovedXid() code. As noted by Noah Misch, btree_xlog_delete_get_latestRemovedXid is critically dependent on the assumption that it's examining a consistent state of the database. This was undocumented though, so the seemingly-unrelated check for no active HS sessions might be thought to be merely an optional optimization. Improve comments, and add an explicit check of reachedConsistency just to be sure. This function returns InvalidTransactionId (thereby killing all HS transactions) in several cases that are not nearly unlikely enough for my taste. This commit doesn't attempt to fix those deficiencies, just document them. Back-patch to 9.2, not from any real functional need but just to keep the branches more closely synced to simplify possible future back-patching. -- Á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