Re: Odd blocking (or massively latent) issue - even with EXPLAIN

From: "Martin French" <Martin(dot)French(at)romaxtech(dot)com>
To: Jim Vanns <james(dot)vanns(at)framestore(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org,pgsql-performance-owner(at)postgresql(dot)org
Subject: Re: Odd blocking (or massively latent) issue - even with EXPLAIN
Date: 2012-07-24 06:50:45
Message-ID: OF7755750C.7073A920-ON80257A45.00249D8E-80257A45.00259C8D@LocalDomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

<html><body><p><tt><font size="2">&gt; &gt; Hi<br>&gt; &gt; <br>&gt; &gt; &gt; <br>&gt; &gt; &gt; We're seeing SELECT statements and even EXPLAIN (no ANAYLZE) <br>&gt; &gt; &gt; statements hang indefinitely until *something* (we don't know what)<br>&gt; &gt; &gt; releases some kind of resource or no longer becomes a massive bottle<br>&gt; &gt; &gt; neck. These are the symptoms.<br>&gt; &gt; <br>&gt; &gt; Is this in pgAdmin? Or psql on the console?<br>&gt; &gt; <br>&gt; psql<br>&gt; <br>&gt; &gt; &gt; However, the system seems healthy - no table ('heavyweight') locks<br>&gt; &gt; are<br>&gt; &gt; &gt; held by any session (this happens with only a few connected<br>&gt; &gt; sessions),<br>&gt; &gt; &gt; all indexes are used correctly, other transactions are writing data<br>&gt; &gt; (we<br>&gt; &gt; &gt; generally only have a few sessions running at a time - perhaps 10)<br>&gt; &gt; etc.<br>&gt; &gt; &gt; etc. In fact, we are writing (or bgwriter is), 2-3 hundred MB/s<br>&gt; &gt; &gt; sometimes.<br>&gt; &gt; <br>&gt; &gt; What is shown in &quot;top&quot; and &quot;iostat&quot; whilst the queries are running?<br>&gt; <br>&gt; Generally, lots of CPU churn (90-100%) and a fair bit of I/O wait.<br>&gt; iostat reports massive reads (up to 300MB/s).<br></font></tt><br><tt><font size="2">This looks like this is a pure IO issue. You mentioned that this was a software RAID system. I wonder if there's some complication there.</font></tt><br><br><tt><font size="2">Have you tried setting the disk queues to deadline?</font></tt><br><br><tt><font size="2">echo &quot;deadline&quot; &gt; /sys/block/{DEVICE-NAME}/queue/scheduler</font></tt><br><br><tt><font size="2">That might help. But to be honest, it really does sound disk/software raid related with the CPU and IO being so high.</font></tt><br><br><tt><font size="2">Can you attempt to replicate the problem on another system without software RAID?</font></tt><br><br><tt><font size="2">Also, you might want to try a disk test on the machine, it's 24GB ram right?</font></tt><br><br><tt><font size="2">so, try the following tests on the Postgres data disk (you'll obviously need lots of space for this):</font></tt><br><br><br><tt><font size="2">Write Test: </font></tt><br><tt><font size="2"> time sh -c &quot;dd if=/dev/zero of=bigfile bs=8k count=6000000 &amp;&amp; sync&quot;</font></tt><br><br><tt><font size="2">Read Test:</font></tt><br><tt><font size="2"> time dd if=bigfile of=/dev/null bs=8k</font></tt><br><br><tt><font size="2">( Tests taken from Greg Smiths page: </font></tt><a href="http://www.westnet.com/~gsmith/content/postgresql/pg-disktesting.htm"><font size="3" color="#0000FF" face="serif"><u>http://www.westnet.com/~gsmith/content/postgresql/pg-disktesting.htm</u></font></a><font size="3" face="serif">&nbsp;</font><tt><font size="2">)</font></tt><br><br><tt><font size="2">&gt; <br>&gt; &gt; &gt; <br>&gt; &gt; &gt; We regularly run vacuum analyze at quiet periods - generally 1-2s<br>&gt; &gt; daily.<br>&gt; <br>&gt; (this is to answer to someone who didn't reply to the list)<br>&gt; <br>&gt; We run full scans using vacuumdb so don't just rely on autovacuum. The<br>&gt; small table is so small (&lt;50 tuples) a sequence scan is always<br>&gt; performed.<br>&gt; <br>&gt; &gt; &gt; These sessions (that only read data) that are blocked can block from<br>&gt; &gt; &gt; anything from between only 5 minutes to 10s of hours then<br>&gt; &gt; miraculously<br>&gt; &gt; &gt; complete successfully at once.<br>&gt; &gt; &gt; <br>&gt; &gt; <br>&gt; &gt; Are any &quot;blockers&quot; shown in pg_stat_activity?<br>&gt; <br>&gt; None. Ever. Nothing in pg_locks either.<br>&gt; <br>&gt; &gt; &gt; <br>&gt; &gt; &gt; checkpoint_segments = 128<br>&gt; &gt; &gt; maintenance_work_mem = 256MB<br>&gt; &gt; &gt; synchronous_commit = off<br>&gt; &gt; &gt; random_page_cost = 3.0<br>&gt; &gt; &gt; wal_buffers = 16MB<br>&gt; &gt; &gt; shared_buffers = 8192MB<br>&gt; &gt; &gt; checkpoint_completion_target = 0.9<br>&gt; &gt; &gt; effective_cache_size = 18432MB<br>&gt; &gt; &gt; work_mem = 32MB<br>&gt; &gt; &gt; effective_io_concurrency = 12<br>&gt; &gt; &gt; max_stack_depth = 8MB<br>&gt; &gt; &gt; log_autovacuum_min_duration = 0<br>&gt; &gt; &gt; log_lock_waits = on<br>&gt; &gt; &gt; autovacuum_vacuum_scale_factor = 0.1<br>&gt; &gt; &gt; autovacuum_naptime = 8<br>&gt; &gt; &gt; autovacuum_max_workers = 4<br>&gt; &gt; <br>&gt; &gt; Memory looks reasonably configured to me. effective_cache_size is only<br>&gt; &gt; an indication to the planner and is not actually allocated. <br>&gt; <br>&gt; I realise that.<br>&gt; <br>&gt; &gt; Is anything being written to the logfiles?<br>&gt; <br>&gt; Nothing obvious - and we log a fair amount. No tmp table creations,<br>&gt; no locks held. <br>&gt; <br>&gt; To add to this EXPLAIN reports it took only 0.23ms to run (for example)<br>&gt; whereas the wall clock time is more like 20-30 minutes (or up to n hours<br>&gt; as I said where everything appears to click back into place at the same<br>&gt; time).<br>&gt; <br>&gt; Thanks.<br>&gt; <br></font></tt><br><tt><font size="2">Something else you might want to try is running with a default Postgresql.conf, if the query/explain then runs fine, then that would lead me to believe that there is a configuration issue. Although I'm pretty convinced that it may be the disk set up. </font></tt><br><br><tt><font size="2">Cheers<br></font></tt><font face="sans-serif">=============================================

Romax Technology Limited
Rutherford House
Nottingham Science & Technology Park
Nottingham,
NG7 2PZ
England

Telephone numbers:
+44 (0)115 951 88 00 (main)

For other office locations see:
http://www.romaxtech.com/Contact
=================================
===============
E-mail: info(at)romaxtech(dot)com
Website: www.romaxtech.com
=================================

================
Confidentiality Statement
This transmission is for the addressee only and contains information that is confidential and privileged.
Unless you are the named addressee, or authorised to receive it on behalf of the addressee
you may not copy or use it, or disclose it to anyone else.
If you have received this transmission in error please delete from your system and contact the sender. Thank you for your cooperation.
=================================================</font>
</body></html>

Attachment Content-Type Size
unknown_filename text/html 6.2 KB

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Riaan van den Dool 2012-07-24 07:21:17 Geoserver-PostGIS performance problems
Previous Message Craig Ringer 2012-07-24 00:30:22 Re: Odd blocking (or massively latent) issue - even with EXPLAIN