pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedinvalid memory alloc request size from pg_stat_activity?
6+ messages / 4 participants
[nested] [flat]
* invalid memory alloc request size from pg_stat_activity?
@ 2019-05-06 23:04 James Tomson <james@pushd.com>
2019-05-07 13:37 ` Re: invalid memory alloc request size from pg_stat_activity? Euler Taveira <euler@timbira.com.br>
2019-05-07 14:59 ` Re: invalid memory alloc request size from pg_stat_activity? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: James Tomson @ 2019-05-06 23:04 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: Eric Jensen <ej@pushd.com>
Hello,
We're upgrading from postgresql 9.6 to 10.6 and everything is working fine, but any query against pg_stat_activity results in ERROR: invalid memory alloc request size 1652113408
e.g:
ourdb=> SELECT pid, state, age(query_start, clock_timestamp()), usename, query FROM pg_stat_activity WHERE query != '<IDLE>' AND state != 'idle' ORDER BY age limit 100;
ERROR: invalid memory alloc request size 1652113408
Maybe this has to do with us setting track_activity_query_size=102400? Is there a known safe maximum for that, or could there be some other problem?
Thanks,
James
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: invalid memory alloc request size from pg_stat_activity?
2019-05-06 23:04 invalid memory alloc request size from pg_stat_activity? James Tomson <james@pushd.com>
@ 2019-05-07 13:37 ` Euler Taveira <euler@timbira.com.br>
2019-05-07 14:55 ` Re: invalid memory alloc request size from pg_stat_activity? Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 1 reply; 6+ messages in thread
From: Euler Taveira @ 2019-05-07 13:37 UTC (permalink / raw)
To: James Tomson <james@pushd.com>; +Cc: pgsql-bugs@lists.postgresql.org, Eric Jensen <ej@pushd.com>
Em seg, 6 de mai de 2019 às 20:04, James Tomson <james@pushd.com> escreveu:
>
> ourdb=> SELECT pid, state, age(query_start, clock_timestamp()), usename, query FROM pg_stat_activity WHERE query != '<IDLE>' AND state != 'idle' ORDER BY age limit 100;
> ERROR: invalid memory alloc request size 1652113408
>
That is because it is limited to 1GB - 1.
> Maybe this has to do with us setting track_activity_query_size=102400? Is there a known safe maximum for that, or could there be some other problem?
>
Question is: why do you want to return such a big query text? That's
impractical for admin/monitoring tools. We can usually identify a
query with 1024 bytes (that is the default).
--
Euler Taveira Timbira -
http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: invalid memory alloc request size from pg_stat_activity?
2019-05-06 23:04 invalid memory alloc request size from pg_stat_activity? James Tomson <james@pushd.com>
2019-05-07 13:37 ` Re: invalid memory alloc request size from pg_stat_activity? Euler Taveira <euler@timbira.com.br>
@ 2019-05-07 14:55 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2019-05-07 15:14 ` Re: invalid memory alloc request size from pg_stat_activity? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Alvaro Herrera @ 2019-05-07 14:55 UTC (permalink / raw)
To: Euler Taveira <euler@timbira.com.br>; +Cc: James Tomson <james@pushd.com>; pgsql-bugs@lists.postgresql.org, Eric Jensen <ej@pushd.com>
On 2019-May-07, Euler Taveira wrote:
> Em seg, 6 de mai de 2019 às 20:04, James Tomson <james@pushd.com> escreveu:
> >
> > ourdb=> SELECT pid, state, age(query_start, clock_timestamp()), usename, query FROM pg_stat_activity WHERE query != '<IDLE>' AND state != 'idle' ORDER BY age limit 100;
> > ERROR: invalid memory alloc request size 1652113408
> >
> That is because it is limited to 1GB - 1.
>
> > Maybe this has to do with us setting track_activity_query_size=102400? Is there a known safe maximum for that, or could there be some other problem?
> >
> Question is: why do you want to return such a big query text? That's
> impractical for admin/monitoring tools. We can usually identify a
> query with 1024 bytes (that is the default).
Hmm, but 102400 is only 100kB, nowhere near the 1GB-1 limit, so there's
something odd going on there.
I would start investigating by attaching a debugger and setting a
breakpoint on 'errfinish', then running the above query; past the
backtrace here, as it might be illuminating.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: invalid memory alloc request size from pg_stat_activity?
2019-05-06 23:04 invalid memory alloc request size from pg_stat_activity? James Tomson <james@pushd.com>
2019-05-07 13:37 ` Re: invalid memory alloc request size from pg_stat_activity? Euler Taveira <euler@timbira.com.br>
2019-05-07 14:55 ` Re: invalid memory alloc request size from pg_stat_activity? Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2019-05-07 15:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-05-07 16:22 ` Re: invalid memory alloc request size from pg_stat_activity? James Tomson <james@pushd.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2019-05-07 15:14 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Euler Taveira <euler@timbira.com.br>; James Tomson <james@pushd.com>; pgsql-bugs@lists.postgresql.org, Eric Jensen <ej@pushd.com>
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Hmm, but 102400 is only 100kB, nowhere near the 1GB-1 limit, so there's
> something odd going on there.
I can reproduce the described behavior by also setting max_connections
to something around 16K.
Now, it seems pretty silly to me to be burning in excess of 1GB of shmem
just for the current-query strings, and then that much again in every
backend that reads pg_stat_activity. But should we be telling people they
can't do it? I'm working on a patch to use MemoryContextAllocHuge for
the "localactivity" buffer in pgstat_read_current_status. It might seem
dumb now, but perhaps in ten years it'll be common.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: invalid memory alloc request size from pg_stat_activity?
2019-05-06 23:04 invalid memory alloc request size from pg_stat_activity? James Tomson <james@pushd.com>
2019-05-07 13:37 ` Re: invalid memory alloc request size from pg_stat_activity? Euler Taveira <euler@timbira.com.br>
2019-05-07 14:55 ` Re: invalid memory alloc request size from pg_stat_activity? Alvaro Herrera <alvherre@2ndquadrant.com>
2019-05-07 15:14 ` Re: invalid memory alloc request size from pg_stat_activity? Tom Lane <tgl@sss.pgh.pa.us>
@ 2019-05-07 16:22 ` James Tomson <james@pushd.com>
0 siblings, 0 replies; 6+ messages in thread
From: James Tomson @ 2019-05-07 16:22 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Euler Taveira <euler@timbira.com.br>; pgsql-bugs@lists.postgresql.org, Eric Jensen <ej@pushd.com>
Thanks all - we did have our max_connections set very very high (100k) as we upgraded this db in a load test environment, and did not want to reboot the db after hitting the lower, saner, production limits during load testing.
I am surprised this allocation was taking place for unused connections - I’ve also verified that lowering max_connections to 10K on this instance fixed the issue for us. Much appreciated!
Best,
James
> On May 7, 2019, at 11:14 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
>> Hmm, but 102400 is only 100kB, nowhere near the 1GB-1 limit, so there's
>> something odd going on there.
>
> I can reproduce the described behavior by also setting max_connections
> to something around 16K.
>
> Now, it seems pretty silly to me to be burning in excess of 1GB of shmem
> just for the current-query strings, and then that much again in every
> backend that reads pg_stat_activity. But should we be telling people they
> can't do it? I'm working on a patch to use MemoryContextAllocHuge for
> the "localactivity" buffer in pgstat_read_current_status. It might seem
> dumb now, but perhaps in ten years it'll be common.
>
> regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: invalid memory alloc request size from pg_stat_activity?
2019-05-06 23:04 invalid memory alloc request size from pg_stat_activity? James Tomson <james@pushd.com>
@ 2019-05-07 14:59 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 6+ messages in thread
From: Tom Lane @ 2019-05-07 14:59 UTC (permalink / raw)
To: James Tomson <james@pushd.com>; +Cc: pgsql-bugs@lists.postgresql.org, Eric Jensen <ej@pushd.com>
James Tomson <james@pushd.com> writes:
> We're upgrading from postgresql 9.6 to 10.6 and everything is working fine, but any query against pg_stat_activity results in ERROR: invalid memory alloc request size 1652113408
> e.g:
> ourdb=> SELECT pid, state, age(query_start, clock_timestamp()), usename, query FROM pg_stat_activity WHERE query != '<IDLE>' AND state != 'idle' ORDER BY age limit 100;
> ERROR: invalid memory alloc request size 1652113408
That seems odd ...
> Maybe this has to do with us setting track_activity_query_size=102400?
It wouldn't surprise me if reading pg_stat_activity causes allocation of
track_activity_query_size * max_connections bytes, but unless you also
have max_connections set to some pretty insane value, that wouldn't
be enough to fit this observation.
Did you have these parameters set differently in 9.6?
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-05-07 16:22 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-06 23:04 invalid memory alloc request size from pg_stat_activity? James Tomson <james@pushd.com>
2019-05-07 13:37 ` Euler Taveira <euler@timbira.com.br>
2019-05-07 14:55 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2019-05-07 15:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-05-07 16:22 ` James Tomson <james@pushd.com>
2019-05-07 14:59 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox