Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1alYuP-0001QN-AH for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Mar 2016 09:28:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1alYuO-0006zb-Oj for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Mar 2016 09:28:56 +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_2) (envelope-from ) id 1alYt3-0005Pk-3U for pgsql-hackers@postgresql.org; Thu, 31 Mar 2016 09:27:33 +0000 Received: from dd6038.kasserver.com ([85.13.130.233]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1alYt0-0008Vh-4b for pgsql-hackers@postgresql.org; Thu, 31 Mar 2016 09:27:32 +0000 Received: from [172.26.14.170] (wan3.credativ.com [94.79.138.166]) by dd6038.kasserver.com (Postfix) with ESMTPSA id 43BEF2DC0097 for ; Thu, 31 Mar 2016 11:27:28 +0200 (CEST) Date: Thu, 31 Mar 2016 11:27:27 +0200 From: Bernd Helmle To: pgsql-hackers@postgresql.org Subject: standalone backend PANICs during recovery Message-ID: <00F0B2CEF6D0CEF8A90119D4@eje.credativ.lan> X-Mailer: Mulberry/4.1.0a3 (Mac OS X) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="==========0A4950252DB9C379855E==========" X-Pg-Spam-Score: -1.9 (-) 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 --==========0A4950252DB9C379855E========== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; size=1029 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) { [...] if (!reachedConsistency) elog(PANIC, "btree_xlog_delete_get_latestRemovedXid: cannot operate with inconsistent data"); [...] } There's already an "optimization" before, exiting with InvalidTransactionId in case a HS doesn't count any active backends. In standalone mode however, CountDBBackends() will always return 1 afaik. It looks like btree_xlog_delete_get_latestRemovedXid() needs an additional check for standalone backends, so i came up with the attached patch. This allowed the standalone backend to recover without any problems. -- Thanks Bernd --==========0A4950252DB9C379855E========== Content-Type: application/octet-stream; name="standalone_recover.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="standalone_recover.patch"; size=568 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL2FjY2Vzcy9uYnRyZWUvbmJ0eGxv Zy5jIGIvc3JjL2JhY2tlbmQvYWNjZXNzL25idHJlZS9uYnR4bG9nLmMKaW5k ZXggMmRlYmI4Ny4uMDQ4OTk2OSAxMDA2NDQKLS0tIGEvc3JjL2JhY2tlbmQv YWNjZXNzL25idHJlZS9uYnR4bG9nLmMKKysrIGIvc3JjL2JhY2tlbmQvYWNj ZXNzL25idHJlZS9uYnR4bG9nLmMKQEAgLTYxOCw3ICs2MTgsNyBAQCBidHJl ZV94bG9nX2RlbGV0ZV9nZXRfbGF0ZXN0UmVtb3ZlZFhpZCh4bF9idHJlZV9k ZWxldGUgKnhscmVjKQogCSAqIHN0YXJ0IGp1c3QgYWZ0ZXIgd2UgbG9vay4g IElmIHNvLCBpdCBjYW5ub3QgbmVlZCB0byBjb25mbGljdCwgYnV0IHRoaXMK IAkgKiBjb2Rpbmcgd2lsbCByZXN1bHQgaW4gdGhyb3dpbmcgYSBjb25mbGlj dCBhbnl3YXkuCiAJICovCi0JaWYgKENvdW50REJCYWNrZW5kcyhJbnZhbGlk T2lkKSA9PSAwKQorCWlmICgoQ291bnREQkJhY2tlbmRzKEludmFsaWRPaWQp ID09IDApIHx8ICghSXNQb3N0bWFzdGVyRW52aXJvbm1lbnQpKQogCQlyZXR1 cm4gbGF0ZXN0UmVtb3ZlZFhpZDsKIAogCS8qCg== --==========0A4950252DB9C379855E========== Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --==========0A4950252DB9C379855E==========--