Re: Query on pg_stat_activity table got stuck - Mailing list pgsql-admin

From Tom Lane
Subject Re: Query on pg_stat_activity table got stuck
Date
Msg-id 30687.1557432052@sss.pgh.pa.us
Whole thread Raw
In response to Re: Query on pg_stat_activity table got stuck  (Jeremy Schneider <schnjere@amazon.com>)
Responses Re: Query on pg_stat_activity table got stuck
Re: Query on pg_stat_activity table got stuck
List pgsql-admin
Jeremy Schneider <schnjere@amazon.com> writes:
> Seems to me that at a minimum, this loop shouldn't go on forever. Even
> having an arbitrary, crazy high, hard-coded number of attempts before
> failure (like a million) would be better than spinning on the CPU
> forever - which is what we are seeing.

I don't think it's the readers' fault.  The problem is that the
writer is violating the protocol.  If we put an upper limit on
the number of spin cycles on the reader side, we'll just be creating
a new failure mode when a writer gets swapped out at the wrong moment.

IMO we need to (a) get the failure-prone code out of the critical
section, and then (b) fix the pgstat_increment_changecount macros
so that the critical sections around these shmem changes really are
critical sections (ie bump CritSectionCount).  That way, if somebody
makes the same mistake again, at least there'll be a pretty obvious
failure rather than a lot of stuck readers.

            regards, tom lane



pgsql-admin by date:

Previous
From: Jeremy Schneider
Date:
Subject: Re: Query on pg_stat_activity table got stuck
Next
From: neeraj kumar
Date:
Subject: Re: Query on pg_stat_activity table got stuck