pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14714: long running sessions from remote instance seems to hang some times
13+ messages / 6 participants
[nested] [flat]
* BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-19 14:49 josef.machytka@gmail.com
0 siblings, 4 replies; 13+ messages in thread
From: josef.machytka@gmail.com @ 2017-06-19 14:49 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 14714
Logged by: Josef Machytka
Email address: josef.machytka@gmail.com
PostgreSQL version: 9.6.3
Operating system: Debian jessie
Description:
On pg 9.6.* we have sometimes strange problem with some sessions. We
experienced it from bash scripts, golang program and node.js applications.
Environment are Google Compute Engine instances with Debian 8.
Sometimes some session goes into some kind of "drowsy" state and runs
incredibly slowly. It causes some very low disk IO and runs like 20x slower
then usual. This happens mainly when database is under heavy load and it
happens randomly to different tasks. It happens randomly to both connections
from local instance (cronjob running on instance with PG) and remote
connections from other instances.
When we restart task it runs normally. I cannot see any changes in process
priority in OS, process switches between sleeping and running state and I do
not see any locks or waits in pg_stat_activity or pg_locks. Usually all
other processes finish OK and this "drowsy" one runs "for ever..."
We implemented timeouts for PG tasks into our programs to restart tasks but
it very annoying and we have to use long enough timeouts anyway so it delays
tasks.... It happens from time to time also to dblink connections inside pg
function so we had to rewrite our programs which were running without any
problems on PG 9.5. Problems started when we switched to PG 9.6 and we
experienced them on all minor versions - we currently run 9.6.3 and problem
is still present...
Do you please have any advice what to check or what setting might help?
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-19 15:33 Tom Lane <tgl@sss.pgh.pa.us>
parent: josef.machytka@gmail.com
3 siblings, 0 replies; 13+ messages in thread
From: Tom Lane @ 2017-06-19 15:33 UTC (permalink / raw)
To: josef.machytka@gmail.com; +Cc: pgsql-bugs
josef.machytka@gmail.com writes:
> Sometimes some session goes into some kind of "drowsy" state and runs
> incredibly slowly. It causes some very low disk IO and runs like 20x slower
> then usual.
Is it using a lot of CPU time according to ps or vmstat?
> Do you please have any advice what to check or what setting might help?
If it's eating CPU time, try using "perf" to find out where.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-19 15:56 Pavel Stehule <pavel.stehule@gmail.com>
parent: josef.machytka@gmail.com
3 siblings, 1 reply; 13+ messages in thread
From: Pavel Stehule @ 2017-06-19 15:56 UTC (permalink / raw)
To: josef.machytka@gmail.com; +Cc: pgsql-bugs
2017-06-19 16:49 GMT+02:00 <josef.machytka@gmail.com>:
> The following bug has been logged on the website:
>
> Bug reference: 14714
> Logged by: Josef Machytka
> Email address: josef.machytka@gmail.com
> PostgreSQL version: 9.6.3
> Operating system: Debian jessie
> Description:
>
> On pg 9.6.* we have sometimes strange problem with some sessions. We
> experienced it from bash scripts, golang program and node.js applications.
> Environment are Google Compute Engine instances with Debian 8.
>
> Sometimes some session goes into some kind of "drowsy" state and runs
> incredibly slowly. It causes some very low disk IO and runs like 20x slower
> then usual. This happens mainly when database is under heavy load and it
> happens randomly to different tasks. It happens randomly to both
> connections
> from local instance (cronjob running on instance with PG) and remote
> connections from other instances.
>
> When we restart task it runs normally. I cannot see any changes in process
> priority in OS, process switches between sleeping and running state and I
> do
> not see any locks or waits in pg_stat_activity or pg_locks. Usually all
> other processes finish OK and this "drowsy" one runs "for ever..."
>
> We implemented timeouts for PG tasks into our programs to restart tasks but
> it very annoying and we have to use long enough timeouts anyway so it
> delays
> tasks.... It happens from time to time also to dblink connections inside pg
> function so we had to rewrite our programs which were running without any
> problems on PG 9.5. Problems started when we switched to PG 9.6 and we
> experienced them on all minor versions - we currently run 9.6.3 and problem
> is still present...
>
> Do you please have any advice what to check or what setting might help?
>
it can be spin lock issue. Try to use "perf top". Install postgresql-server
debug symbols before.
what is your share buffers configuration?
Regards
Pavel
>
>
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-19 16:31 Jeff Janes <jeff.janes@gmail.com>
parent: josef.machytka@gmail.com
3 siblings, 0 replies; 13+ messages in thread
From: Jeff Janes @ 2017-06-19 16:31 UTC (permalink / raw)
To: josef.machytka@gmail.com; +Cc: pgsql-bugs
On Mon, Jun 19, 2017 at 7:49 AM, <josef.machytka@gmail.com> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14714
> Logged by: Josef Machytka
> Email address: josef.machytka@gmail.com
> PostgreSQL version: 9.6.3
> Operating system: Debian jessie
> Description:
>
> On pg 9.6.* we have sometimes strange problem with some sessions. We
> experienced it from bash scripts, golang program and node.js applications.
> Environment are Google Compute Engine instances with Debian 8.
>
> Sometimes some session goes into some kind of "drowsy" state and runs
> incredibly slowly. It causes some very low disk IO and runs like 20x slower
> then usual. This happens mainly when database is under heavy load and it
> happens randomly to different tasks. It happens randomly to both
> connections
> from local instance (cronjob running on instance with PG) and remote
> connections from other instances.
>
One possibility is that another process inserted a bunch of new tuples and
committed them, and now the existing session has to dig through all those
new tuples and ignore them because they are too new to be visible to it.
This would particularly be a problem where the queries have things like
"MAX(indexed_column)" or "ORDER BY indexed_column desc LIMIT 1" and where
the newly insert tuples all have values which are at the end of the range
being probed by that query. Although I don't know why this would have
gotten worse from 9.5 to 9.6. The change should have been in the other
direction.
Is this on a master or on a hot standby?
Cheers,
Jeff
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-23 09:26 Josef Machytka <josef.machytka@gmail.com>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: Josef Machytka @ 2017-06-23 09:26 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-bugs
Today I got several sessions in this "drowsy" state and it almost caused
collapse of the whole reporting system because aggregations were not fully
calculated.
Looks like now on PG 9.6.3 is this problem even worse then on previous
9.6.x subversions...
I checked "top", "iotop -u postgres", "perf top" and "perf top -u postgres"
and as far as I could see those sessions are running although they are
marked as "S" sleeping in "top" command almost all the time.
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-23 09:37 Pavel Stehule <pavel.stehule@gmail.com>
parent: Josef Machytka <josef.machytka@gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: Pavel Stehule @ 2017-06-23 09:37 UTC (permalink / raw)
To: Josef Machytka <josef.machytka@gmail.com>; +Cc: pgsql-bugs
2017-06-23 11:26 GMT+02:00 Josef Machytka <josef.machytka@gmail.com>:
> Today I got several sessions in this "drowsy" state and it almost caused
> collapse of the whole reporting system because aggregations were not fully
> calculated.
> Looks like now on PG 9.6.3 is this problem even worse then on previous
> 9.6.x subversions...
>
> I checked "top", "iotop -u postgres", "perf top" and "perf top -u
> postgres" and as far as I could see those sessions are running although
> they are marked as "S" sleeping in "top" command almost all the time.
> From time to time they cause very low CPU load, something like from 0,5 to
> 0,8% - which is visible only in "perf" output. In "top" I see almost all
> the time 0.0% on CPU.
> The same with disk IO - iotop shows only a few MB/s from time to time.
> They are marked as "active" in "pg_stat_activity" and no wait events are
> shown.
>
> GCE Instance has Debian 8, 10 CPUs, 46GB RAM
> Our database has 2390 GB is distributed over 3 different tablespaces on 3
> different GCE standard persistent disks, wal logs and temp tablespace have
> separate disk.
>
> Out pg config is:
> shared_buffers = 8GB
> temp_buffers = 512MB
> work_mem = 192MB
> maintenance_work_mem = 2GB
> max_connections = 150
> max_wal_size = 8GB
> min_wal_size = 4GB
> max_worker_processes = 50
> max_parallel_workers_per_gather = 4
>
> There are several procedures which set work_mem to 256MB because tests
> showed it speeds up processing really significantly.
> Reason is when we switched from PG 9.5 to PG 9.6 we found that many old
> queries had suddenly very bad explain plan and very long run time.
> Only setting work_mem from previous 64MB to the current values helped to
> get the same or better results for those queries on 9.6.
> Of course we upgraded instance with more memory. But we do not use swap.
>
> Shall I look for some special perf symbols in output? Or is there a
> possibility to debug it deeper?
>
>
what is perf top output?
you can install debug symbols for postgres and for kernel
https://wiki.debian.org/DebugPackage
Regards
Pavel
Thanks
>
> Josef
>
>
> On 19 June 2017 at 17:56, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
>>
>>
>> 2017-06-19 16:49 GMT+02:00 <josef.machytka@gmail.com>:
>>
>>> The following bug has been logged on the website:
>>>
>>> Bug reference: 14714
>>> Logged by: Josef Machytka
>>> Email address: josef.machytka@gmail.com
>>> PostgreSQL version: 9.6.3
>>> Operating system: Debian jessie
>>> Description:
>>>
>>> On pg 9.6.* we have sometimes strange problem with some sessions. We
>>> experienced it from bash scripts, golang program and node.js
>>> applications.
>>> Environment are Google Compute Engine instances with Debian 8.
>>>
>>> Sometimes some session goes into some kind of "drowsy" state and runs
>>> incredibly slowly. It causes some very low disk IO and runs like 20x
>>> slower
>>> then usual. This happens mainly when database is under heavy load and it
>>> happens randomly to different tasks. It happens randomly to both
>>> connections
>>> from local instance (cronjob running on instance with PG) and remote
>>> connections from other instances.
>>>
>>> When we restart task it runs normally. I cannot see any changes in
>>> process
>>> priority in OS, process switches between sleeping and running state and
>>> I do
>>> not see any locks or waits in pg_stat_activity or pg_locks. Usually all
>>> other processes finish OK and this "drowsy" one runs "for ever..."
>>>
>>> We implemented timeouts for PG tasks into our programs to restart tasks
>>> but
>>> it very annoying and we have to use long enough timeouts anyway so it
>>> delays
>>> tasks.... It happens from time to time also to dblink connections inside
>>> pg
>>> function so we had to rewrite our programs which were running without any
>>> problems on PG 9.5. Problems started when we switched to PG 9.6 and we
>>> experienced them on all minor versions - we currently run 9.6.3 and
>>> problem
>>> is still present...
>>>
>>> Do you please have any advice what to check or what setting might help?
>>>
>>
>> it can be spin lock issue. Try to use "perf top". Install
>> postgresql-server debug symbols before.
>>
>> what is your share buffers configuration?
>>
>> Regards
>>
>> Pavel
>>
>>>
>>>
>>>
>>>
>>> --
>>> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-bugs
>>>
>>
>>
>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-23 11:37 Josef Machytka <josef.machytka@gmail.com>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: Josef Machytka @ 2017-06-23 11:37 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-bugs
sorry, here is file with sample - basically several group by aggregations
over different partitioned tables have been locked in this "drowsy" state
On 23 June 2017 at 11:37, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
>
> 2017-06-23 11:26 GMT+02:00 Josef Machytka <josef.machytka@gmail.com>:
>
>> Today I got several sessions in this "drowsy" state and it almost caused
>> collapse of the whole reporting system because aggregations were not fully
>> calculated.
>> Looks like now on PG 9.6.3 is this problem even worse then on previous
>> 9.6.x subversions...
>>
>> I checked "top", "iotop -u postgres", "perf top" and "perf top -u
>> postgres" and as far as I could see those sessions are running although
>> they are marked as "S" sleeping in "top" command almost all the time.
>> From time to time they cause very low CPU load, something like from 0,5
>> to 0,8% - which is visible only in "perf" output. In "top" I see almost all
>> the time 0.0% on CPU.
>> The same with disk IO - iotop shows only a few MB/s from time to time.
>> They are marked as "active" in "pg_stat_activity" and no wait events are
>> shown.
>>
>> GCE Instance has Debian 8, 10 CPUs, 46GB RAM
>> Our database has 2390 GB is distributed over 3 different tablespaces on 3
>> different GCE standard persistent disks, wal logs and temp tablespace have
>> separate disk.
>>
>> Out pg config is:
>> shared_buffers = 8GB
>> temp_buffers = 512MB
>> work_mem = 192MB
>> maintenance_work_mem = 2GB
>> max_connections = 150
>> max_wal_size = 8GB
>> min_wal_size = 4GB
>> max_worker_processes = 50
>> max_parallel_workers_per_gather = 4
>>
>> There are several procedures which set work_mem to 256MB because tests
>> showed it speeds up processing really significantly.
>> Reason is when we switched from PG 9.5 to PG 9.6 we found that many old
>> queries had suddenly very bad explain plan and very long run time.
>> Only setting work_mem from previous 64MB to the current values helped to
>> get the same or better results for those queries on 9.6.
>> Of course we upgraded instance with more memory. But we do not use swap.
>>
>> Shall I look for some special perf symbols in output? Or is there a
>> possibility to debug it deeper?
>>
>>
> what is perf top output?
>
> you can install debug symbols for postgres and for kernel
> https://wiki.debian.org/DebugPackage
>
> Regards
>
> Pavel
>
> Thanks
>>
>> Josef
>>
>>
>> On 19 June 2017 at 17:56, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>>
>>>
>>>
>>> 2017-06-19 16:49 GMT+02:00 <josef.machytka@gmail.com>:
>>>
>>>> The following bug has been logged on the website:
>>>>
>>>> Bug reference: 14714
>>>> Logged by: Josef Machytka
>>>> Email address: josef.machytka@gmail.com
>>>> PostgreSQL version: 9.6.3
>>>> Operating system: Debian jessie
>>>> Description:
>>>>
>>>> On pg 9.6.* we have sometimes strange problem with some sessions. We
>>>> experienced it from bash scripts, golang program and node.js
>>>> applications.
>>>> Environment are Google Compute Engine instances with Debian 8.
>>>>
>>>> Sometimes some session goes into some kind of "drowsy" state and runs
>>>> incredibly slowly. It causes some very low disk IO and runs like 20x
>>>> slower
>>>> then usual. This happens mainly when database is under heavy load and it
>>>> happens randomly to different tasks. It happens randomly to both
>>>> connections
>>>> from local instance (cronjob running on instance with PG) and remote
>>>> connections from other instances.
>>>>
>>>> When we restart task it runs normally. I cannot see any changes in
>>>> process
>>>> priority in OS, process switches between sleeping and running state and
>>>> I do
>>>> not see any locks or waits in pg_stat_activity or pg_locks. Usually all
>>>> other processes finish OK and this "drowsy" one runs "for ever..."
>>>>
>>>> We implemented timeouts for PG tasks into our programs to restart tasks
>>>> but
>>>> it very annoying and we have to use long enough timeouts anyway so it
>>>> delays
>>>> tasks.... It happens from time to time also to dblink connections
>>>> inside pg
>>>> function so we had to rewrite our programs which were running without
>>>> any
>>>> problems on PG 9.5. Problems started when we switched to PG 9.6 and we
>>>> experienced them on all minor versions - we currently run 9.6.3 and
>>>> problem
>>>> is still present...
>>>>
>>>> Do you please have any advice what to check or what setting might help?
>>>>
>>>
>>> it can be spin lock issue. Try to use "perf top". Install
>>> postgresql-server debug symbols before.
>>>
>>> what is your share buffers configuration?
>>>
>>> Regards
>>>
>>> Pavel
>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgsql-bugs
>>>>
>>>
>>>
>>
>
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
perfoutput.txt (text/plain, 8.1K) download
Failed to open /postgres_exporter, continuing without symbols
Failed to open /bin/node_exporter, continuing without symbols
[H[2J
PerfTop: 2426 irqs/sec kernel:93.7% exact: 0.0% [4000Hz cpu-clock], (all, 10 CPUs)
-------------------------------------------------------------------------------
6.96% postgres [.] hash_search_with_hash_value
5.80% [kernel] [k] copy_user_enhanced_fast_string
4.06% [kernel] [k] _raw_spin_unlock_irqrestore
2.32% postgres [.] hash_any
2.32% postgres [.] 0x00000000000acf59
2.13% perf_3.16 [.] rb_next
1.93% [kernel] [k] format_decode
1.93% [kernel] [k] put_page
1.93% postgres [.] ExecProject
1.74% [kernel] [k] finish_task_switch
1.74% [kernel] [k] kallsyms_expand_symbol.constprop.3
1.74% postgres [.] slot_getattr
1.55% [kernel] [k] __wake_up_bit
1.35% [kernel] [k] get_page_from_freelist
1.35% [kernel] [k] vsnprintf
1.35% postgres [.] ExecAgg
1.16% [kernel] [k] shrink_page_list
1.16% perf_3.16 [.] 0x0000000000071be4
1.16% postgres [.] execTuplesMatch
1.16% postgres [.] slot_getsomeattrs
[H[2J
PerfTop: 22203 irqs/sec kernel:93.6% exact: 0.0% [4000Hz cpu-clock], (all, 10 CPUs)
-------------------------------------------------------------------------------
8.70% postgres [.] hash_search_with_hash_value
5.51% [kernel] [k] copy_user_enhanced_fast_string
4.46% [kernel] [k] _raw_spin_unlock_irqrestore
3.43% postgres [.] hash_any
2.70% [kernel] [k] finish_task_switch
2.28% postgres [.] slot_getattr
2.06% postgres [.] 0x00000000000acf59
1.82% postgres [.] HeapTupleSatisfiesMVCC
1.77% [kernel] [k] get_page_from_freelist
1.67% postgres [.] ExecAgg
1.64% postgres [.] heap_getnext
1.55% postgres [.] ExecProject
1.33% [kernel] [k] __wake_up_bit
1.26% postgres [.] execTuplesMatch
1.25% [kernel] [k] put_page
1.24% [kernel] [k] shrink_active_list
1.14% postgres [.] ExecProcNode
1.13% postgres [.] LockBufHdr
1.12% postgres [.] slot_getsomeattrs
1.10% [kernel] [k] copy_page_to_iter
[H[2J
PerfTop: 24527 irqs/sec kernel:94.6% exact: 0.0% [4000Hz cpu-clock], (all, 10 CPUs)
-------------------------------------------------------------------------------
8.51% postgres [.] hash_search_with_hash_value
6.03% [kernel] [k] copy_user_enhanced_fast_string
4.49% [kernel] [k] _raw_spin_unlock_irqrestore
3.14% postgres [.] hash_any
3.03% [kernel] [k] finish_task_switch
2.64% postgres [.] slot_getattr
2.02% postgres [.] heap_getnext
1.90% postgres [.] 0x00000000000acf59
1.80% [kernel] [k] get_page_from_freelist
1.76% postgres [.] HeapTupleSatisfiesMVCC
1.67% postgres [.] ExecAgg
1.56% [kernel] [k] copy_page_to_iter
1.44% postgres [.] execTuplesMatch
1.36% postgres [.] ExecProject
1.33% postgres [.] LockBufHdr
1.29% [kernel] [k] put_page
1.22% postgres [.] ExecProcNode
1.14% [kernel] [k] __wake_up_bit
1.11% [kernel] [k] shrink_active_list
1.09% postgres [.] slot_getsomeattrs
[H[2J
PerfTop: 23917 irqs/sec kernel:94.5% exact: 0.0% [4000Hz cpu-clock], (all, 10 CPUs)
-------------------------------------------------------------------------------
8.00% postgres [.] hash_search_with_hash_value
6.18% [kernel] [k] copy_user_enhanced_fast_string
4.91% [kernel] [k] _raw_spin_unlock_irqrestore
3.20% [kernel] [k] finish_task_switch
3.04% postgres [.] hash_any
2.73% postgres [.] slot_getattr
1.94% postgres [.] 0x00000000000acf59
1.89% postgres [.] heap_getnext
1.77% [kernel] [k] get_page_from_freelist
1.76% postgres [.] ExecAgg
1.69% postgres [.] HeapTupleSatisfiesMVCC
1.50% [kernel] [k] copy_page_to_iter
1.41% postgres [.] execTuplesMatch
1.35% postgres [.] ExecProject
1.27% [kernel] [k] put_page
1.26% postgres [.] LockBufHdr
1.15% postgres [.] ExecProcNode
1.12% [kernel] [k] shrink_active_list
1.07% postgres [.] slot_getsomeattrs
1.07% [kernel] [k] __do_softirq
[H[2J
PerfTop: 30872 irqs/sec kernel:95.1% exact: 0.0% [4000Hz cpu-clock], (all, 10 CPUs)
-------------------------------------------------------------------------------
7.78% postgres [.] hash_search_with_hash_value
5.99% [kernel] [k] copy_user_enhanced_fast_string
4.88% [kernel] [k] _raw_spin_unlock_irqrestore
3.32% [kernel] [k] finish_task_switch
3.02% postgres [.] hash_any
2.48% postgres [.] slot_getattr
1.96% postgres [.] 0x00000000000acf59
1.78% postgres [.] heap_getnext
1.75% [kernel] [k] get_page_from_freelist
1.64% postgres [.] HeapTupleSatisfiesMVCC
1.50% postgres [.] ExecAgg
1.35% [kernel] [k] copy_page_to_iter
1.35% postgres [.] ExecProject
1.34% postgres [.] execTuplesMatch
1.22% postgres [.] LockBufHdr
1.20% [kernel] [k] __wake_up_bit
1.16% [kernel] [k] put_page
1.13% postgres [.] ExecProcNode
1.06% [kernel] [k] shrink_active_list
1.05% [kernel] [k] __do_softirq
[H[2J
PerfTop: 26788 irqs/sec kernel:94.7% exact: 0.0% [4000Hz cpu-clock], (all, 10 CPUs)
-------------------------------------------------------------------------------
7.64% postgres [.] hash_search_with_hash_value
5.95% [kernel] [k] copy_user_enhanced_fast_string
5.15% [kernel] [k] _raw_spin_unlock_irqrestore
3.34% [kernel] [k] finish_task_switch
2.96% postgres [.] hash_any
2.48% postgres [.] slot_getattr
1.96% postgres [.] 0x00000000000acf59
1.79% postgres [.] heap_getnext
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-23 14:14 Tom Lane <tgl@sss.pgh.pa.us>
parent: Josef Machytka <josef.machytka@gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: Tom Lane @ 2017-06-23 14:14 UTC (permalink / raw)
To: Josef Machytka <josef.machytka@gmail.com>; +Cc: Pavel Stehule <pavel.stehule@gmail.com>; pgsql-bugs
Josef Machytka <josef.machytka@gmail.com> writes:
> sorry, here is file with sample - basically several group by aggregations
> over different partitioned tables have been locked in this "drowsy" state
The amount of time being spent in the kernel is strikingly high. I wonder
if you're seeing some variant of the old "context swap storm" problem.
Try watching the output of "vmstat 1" for awhile to see if the cs rate
is high.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-23 15:31 Josef Machytka <josef.machytka@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 13+ messages in thread
From: Josef Machytka @ 2017-06-23 15:31 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Pavel Stehule <pavel.stehule@gmail.com>; pgsql-bugs
If there are no queries on database I see number of context switches from
~900 to ~1500.
I checked our monitoring based on node_exporter, Prometheus and Grafana and
when this "drowsiness" of sessions happens I see number of context switches
from ~10 000 to ~25 000 with a few peeks ~28 000.
But similar numbers or even slightly higher I see also in other cases of
high load on the database and they did not caused any "drowsy" sessions. In
fact monitoring does not show any significant differences between cases
with "drowsy" sessions and without them...If you have some advices about
what else to monitor I will add.
On 23 June 2017 at 16:14, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Josef Machytka <josef.machytka@gmail.com> writes:
> > sorry, here is file with sample - basically several group by aggregations
> > over different partitioned tables have been locked in this "drowsy" state
>
> The amount of time being spent in the kernel is strikingly high. I wonder
> if you're seeing some variant of the old "context swap storm" problem.
> Try watching the output of "vmstat 1" for awhile to see if the cs rate
> is high.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-23 16:57 Andres Freund <andres@anarazel.de>
parent: josef.machytka@gmail.com
3 siblings, 1 reply; 13+ messages in thread
From: Andres Freund @ 2017-06-23 16:57 UTC (permalink / raw)
To: josef.machytka@gmail.com; +Cc: pgsql-bugs
Hi,
On 2017-06-19 14:49:07 +0000, josef.machytka@gmail.com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14714
> Logged by: Josef Machytka
> Email address: josef.machytka@gmail.com
> PostgreSQL version: 9.6.3
> Operating system: Debian jessie
> Description:
>
> On pg 9.6.* we have sometimes strange problem with some sessions. We
> experienced it from bash scripts, golang program and node.js applications.
> Environment are Google Compute Engine instances with Debian 8.
>
> Sometimes some session goes into some kind of "drowsy" state and runs
> incredibly slowly. It causes some very low disk IO and runs like 20x slower
> then usual. This happens mainly when database is under heavy load and it
> happens randomly to different tasks. It happens randomly to both connections
> from local instance (cronjob running on instance with PG) and remote
> connections from other instances.
>
> When we restart task it runs normally. I cannot see any changes in process
> priority in OS, process switches between sleeping and running state and I do
> not see any locks or waits in pg_stat_activity or pg_locks. Usually all
> other processes finish OK and this "drowsy" one runs "for ever..."
Which version of the os & kernel is this? This kind of sounds like the
symptoms that we've observed more frequently a while ago with
the kernel's transparent_hugepages management.
Greetings,
Andres Freund
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-26 10:27 Josef Machytka <josef.machytka@gmail.com>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 13+ messages in thread
From: Josef Machytka @ 2017-06-26 10:27 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-bugs
Debian 8:
Linux <hostname> 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u1 (2017-06-18)
x86_64 GNU/Linux
On 23 June 2017 at 18:57, Andres Freund <andres@anarazel.de> wrote:
> Hi,
>
> On 2017-06-19 14:49:07 +0000, josef.machytka@gmail.com wrote:
> > The following bug has been logged on the website:
> >
> > Bug reference: 14714
> > Logged by: Josef Machytka
> > Email address: josef.machytka@gmail.com
> > PostgreSQL version: 9.6.3
> > Operating system: Debian jessie
> > Description:
> >
> > On pg 9.6.* we have sometimes strange problem with some sessions. We
> > experienced it from bash scripts, golang program and node.js
> applications.
> > Environment are Google Compute Engine instances with Debian 8.
> >
> > Sometimes some session goes into some kind of "drowsy" state and runs
> > incredibly slowly. It causes some very low disk IO and runs like 20x
> slower
> > then usual. This happens mainly when database is under heavy load and it
> > happens randomly to different tasks. It happens randomly to both
> connections
> > from local instance (cronjob running on instance with PG) and remote
> > connections from other instances.
> >
> > When we restart task it runs normally. I cannot see any changes in
> process
> > priority in OS, process switches between sleeping and running state and
> I do
> > not see any locks or waits in pg_stat_activity or pg_locks. Usually all
> > other processes finish OK and this "drowsy" one runs "for ever..."
>
> Which version of the os & kernel is this? This kind of sounds like the
> symptoms that we've observed more frequently a while ago with
> the kernel's transparent_hugepages management.
>
> Greetings,
>
> Andres Freund
>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-06-26 15:40 Andres Freund <andres@anarazel.de>
parent: Josef Machytka <josef.machytka@gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: Andres Freund @ 2017-06-26 15:40 UTC (permalink / raw)
To: Josef Machytka <josef.machytka@gmail.com>; +Cc: pgsql-bugs
Hi,
(please don't top-quote on this list)
On 2017-06-26 12:27:04 +0200, Josef Machytka wrote:
> Debian 8:
> Linux <hostname> 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u1 (2017-06-18)
> x86_64 GNU/Linux
You should chekc the following parameters:
cat /proc/sys/vm/zone_reclaim_mode
cat /sys/kernel/mm/transparent_hugepage/enabled
and disable them:
echo 0 > /proc/sys/vm/zone_reclaim_mode
echo never > /sys/kernel/mm/transparent_hugepage/enabled
- Andres
Greetings,
Andres Freund
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: BUG #14714: long running sessions from remote instance seems to hang some times
@ 2017-07-06 09:26 Josef Machytka <josef.machytka@gmail.com>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 13+ messages in thread
From: Josef Machytka @ 2017-07-06 09:26 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-bugs
Hi,
thank you for an advice - I set it and tested for several days.
Good news is we do not have "drowsy" sessions any more.
But performance of queries on huge tables went seriously down. Even with
parallel processing.
It is understandable regarding memory management but not sustainable for
the future since our tables are growing almost exponentially. In these days
we have weekly increase in size >100GB and it goes still higher. Database
now have 2,5 TB. We had to move some of our queries from PostgreSQL to
Bigquery because performance was really bad...
I checked history of this database and previously PostgreSQL 9.5 was
running on Google GCE instance with Ubuntu 14.04 now we have new instance
with Debian 8 and PostgeSQL 9.6.
On previous instance with Ubuntu we did not have all these problems at all.
I checked and Ubuntu 14.04 has by default hugepages enabled (value
“always”) + fixed setting of number of huge pages but Debian 8 has default
setting “madvise” - memory adviser.
Please has someone here some deeper experiences with differences between
Ubuntu and Debian as environment for PostgreSQL as highly used OLAP
database? Because so far it looks like switching to Debian was rather bad
choice....
Thanks
Josef
^ permalink raw reply [nested|flat] 13+ messages in thread
end of thread, other threads:[~2017-07-06 09:26 UTC | newest]
Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-06-19 14:49 BUG #14714: long running sessions from remote instance seems to hang some times josef.machytka@gmail.com
2017-06-19 15:33 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-06-19 15:56 ` Pavel Stehule <pavel.stehule@gmail.com>
2017-06-23 09:26 ` Josef Machytka <josef.machytka@gmail.com>
2017-06-23 09:37 ` Pavel Stehule <pavel.stehule@gmail.com>
2017-06-23 11:37 ` Josef Machytka <josef.machytka@gmail.com>
2017-06-23 14:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-06-23 15:31 ` Josef Machytka <josef.machytka@gmail.com>
2017-06-19 16:31 ` Jeff Janes <jeff.janes@gmail.com>
2017-06-23 16:57 ` Andres Freund <andres@anarazel.de>
2017-06-26 10:27 ` Josef Machytka <josef.machytka@gmail.com>
2017-06-26 15:40 ` Andres Freund <andres@anarazel.de>
2017-07-06 09:26 ` Josef Machytka <josef.machytka@gmail.com>
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