Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YccoJ-0001nF-DH for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2015 16:45:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YccoI-0008Ov-OT for pgsql-bugs@arkaria.postgresql.org; Mon, 30 Mar 2015 16:45:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YccoG-0008ME-UD for pgsql-bugs@postgresql.org; Mon, 30 Mar 2015 16:45:08 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ycco4-0008Pd-FP for pgsql-bugs@postgresql.org; Mon, 30 Mar 2015 16:45:07 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 0388E5F7B0; Mon, 30 Mar 2015 12:44:54 -0400 (EDT) Date: Mon, 30 Mar 2015 12:44:54 -0400 From: Stephen Frost To: Tom Lane Cc: root@simply.name, pgsql-bugs@postgresql.org Subject: Re: BUG #12918: Segfault in BackendIdGetTransactionIds Message-ID: <20150330164454.GC3663@tamriel.snowman.net> References: <20150330162247.2492.923@wrigleys.postgresql.org> <17494.1427733227@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="v6ieFHm5OYqyo94Y" Content-Disposition: inline In-Reply-To: <17494.1427733227@sss.pgh.pa.us> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-46-generic (x86_64) X-Uptime: 12:36:53 up 10 days, 22:25, 4 users, load average: 0.01, 0.04, 0.08 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --v6ieFHm5OYqyo94Y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tom Lane (tgl@sss.pgh.pa.us) wrote: > root@simply.name writes: > > After upgrading from 9.3.6 to 9.4.1 (both installed from packages on > > yum.postgresql.org) we have started getting segfaults of different back= ends. > > Backtraces of all coredumps look similar: > > (gdb) bt > > #0 0x000000000066bf9b in BackendIdGetTransactionIds (backendID=3D > optimized out>, xid=3D0x7f2a1b714798, xmin=3D0x7f2a1b71479c) at sinvala= dt.c:426 > > #1 0x00000000006287f4 in pgstat_read_current_status () at pgstat.c:2871 > > #2 0x0000000000628879 in pgstat_fetch_stat_numbackends () at pgstat.c:= 2342 >=20 > Hmm ... looks to me like BackendIdGetTransactionIds is simply busted. > It supposes that there are no inactive entries in the sinval array > within the range 0 .. lastBackend. But there can be, in which case > dereferencing stateP->proc crashes. The reason it's hard to reproduce > is the relatively narrow window between where pgstat_read_current_status > saw the backend as active and where we're inspecting its sinval entry. As an immediate short-term workaround, from what I can tell,=20 disabling calls to pg_stat_activity, and pg_stat_database (views), and pg_stat_get_activity, pg_stat_get_backend_idset, and pg_stat_get_db_numbackends (functions) should prevent triggering this bug. These are likely being run by a monitoring system (eg: check_postgres =66rom Nagios). Thanks! Stephen --v6ieFHm5OYqyo94Y Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJVGX2GAAoJEO1sijiDR2RVdvwQAKrtYT1BEknSD+tnFS4kzeHJ ozdKrb3Uhg8n56WjyykFlxCl93S0iYbGEZZWzBzCH0Z1/Sh1o7XsVWU8z2i6ZDOY qn3nwLLkEaWMd5UxtNDtbH0b3xS8lQF6PwOGIicneex1sRCcm+44AOeIZyWOcHHR CBHKlSjnSKRCL1SPWrPSZyA7piziNxJyKEqWfGx3WW2qZ6q99vOMudJzcIXp7oc8 LZ0O3bwQYqfQoQReqpqHJx0+qIcZYqdMRXxCowSCaZAI+qw72zc78/OUpe4bpYCM /a3d3iGOivRswTljbsnxfiFspfX2zVxO10WmCue4Clw9dyOV4zPEIWwmIYHLSHPv pI2dR2uZ4WK1735qgFw40Ili2nljOnxW6Pplme1S2vmg1dD/qLL2LUBwaFBju3Qh Sf2chI1Ho/Mhq8byvEo8YqXS6Ct2rccj/hNKPAZK/mQBM0TAFDFNjUBAAxWRzFLV 0Nq1aj0KMIq4+kWdtcYdg1BdSWJbnPR7UOhBC9wb+aDnzAXUqpSDDd3ltwub9zYt Kw9oQejCWEW15fAnBwMzOeBJaEuDi01hW8yQ26ebntBsNImUHeK5UUoHps9NRPvu eNo/ft4vk5jwLPA3usw7F8/5M4CvTvV64XHX1Oi9EYG0HZ6zeKnrvfuW00a1wNu9 xBQ+K1o6HaIqaVO6aalC =Dhql -----END PGP SIGNATURE----- --v6ieFHm5OYqyo94Y--