Re: BUG #12918: Segfault in BackendIdGetTransactionIds - Mailing list pgsql-bugs

From Vladimir Borodin
Subject Re: BUG #12918: Segfault in BackendIdGetTransactionIds
Date
Msg-id 3F14158B-5484-43B4-B57A-0A3C87121C4F@simply.name
Whole thread Raw
In response to Re: BUG #12918: Segfault in BackendIdGetTransactionIds  (Stephen Frost <sfrost@snowman.net>)
Responses Re: BUG #12918: Segfault in BackendIdGetTransactionIds  (Stephen Frost <sfrost@snowman.net>)
List pgsql-bugs
> 30 =D0=BC=D0=B0=D1=80=D1=82=D0=B0 2015 =D0=B3., =D0=B2 19:44, Stephen =
Frost <sfrost@snowman.net> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0=
):
>=20
> * Tom Lane (tgl@sss.pgh.pa.us <mailto: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 =
backends.
>>> Backtraces of all coredumps look similar:
>>> (gdb) bt
>>> #0  0x000000000066bf9b in BackendIdGetTransactionIds =
(backendID=3D<value
>>> optimized out>, xid=3D0x7f2a1b714798, xmin=3D0x7f2a1b71479c) at =
sinvaladt.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.
>=20
> 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.

I suppose, pg_stat_replication should not be asked too. We have already =
done that on most critical databases but it is hard to be blind :(

>=20
> These are likely being run by a monitoring system (eg: check_postgres
> from Nagios).
>=20
>     Thanks!
>=20
>         Stephen


--
May the force be with you=E2=80=A6
https://simply.name

pgsql-bugs by date:

Previous
From: Stephen Frost
Date:
Subject: Re: BUG #12918: Segfault in BackendIdGetTransactionIds
Next
From: Stephen Frost
Date:
Subject: Re: BUG #12918: Segfault in BackendIdGetTransactionIds