Re: Query on pg_stat_activity table got stuck

From: neeraj kumar <neeru(dot)cse(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeremy Schneider <schnjere(at)amazon(dot)com>, pgsql-admin(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Query on pg_stat_activity table got stuck
Date: 2019-05-10 03:34:37
Message-ID: CAPR3Wj72j3GojE1xV3b__WccZYcc7M0w=WfYV5G=UKgEXDqOWA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Tom, may be I didn't make my point clear.
There are two issues :
1) Why this value was left as odd
2) Why backend entry is still pending in beentry for backend process even
after it was killed/terminated.

I am talking about 2nd issue. My understanding is query on pg_stat_activity
goes via all backend entries via beentry and it finds this wrong/corrupted
entry. When a process terminates, ideally this backend entry into beentery
should have also been cleaned. But why this still there? Whose
responsibility it is to remove entry from beentry when process terminates ?
May be that part is broken?

Ideally this issue should have stayed till this process was active. If
entry from beentry would have been removed after process was killed, system
should have auto recovered.

On Thu, May 9, 2019 at 8:25 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> neeraj kumar <neeru(dot)cse(at)gmail(dot)com> writes:
> > We got more information about this issue. There is one backend process
> > still present into beentry which has changecount as odd value. However
> this
> > process is long gone/terminated. It means when this process was
> > killed/terminated its entry was not cleaned from beentry list. There
> seems
> > to be some shutdown hook which cleans beentry if process is
> > killed/terminated that somehow was not kicked off ?
>
> No, that's the point: there isn't any such cleanup code. The design
> idea here was that we'd only have short straight-line code segments
> with no possible way to throw an error while changecount is odd.
> Then somebody abused the heck out of that ...
>
> regards, tom lane
>

--
-------------------------------------
Thanks
Neeraj Kumar,
+1 (206) 427-7267

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2019-05-10 04:29:18 Re: Query on pg_stat_activity table got stuck
Previous Message Tom Lane 2019-05-10 03:25:01 Re: Query on pg_stat_activity table got stuck

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-05-10 04:29:18 Re: Query on pg_stat_activity table got stuck
Previous Message Tom Lane 2019-05-10 03:25:01 Re: Query on pg_stat_activity table got stuck