pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: psql is hanging
Date: Tue, 4 Dec 2018 18:36:28 -0600
Message-ID: <14c6e880-0a16-9bd0-42d1-da45d59a22ed@gmail.com> (raw)
In-Reply-To: <CAK6G+57yG5W+ZSShNjHMKjKPpYB-enTaWKcwC5k5wa4Oew5zXA@mail.gmail.com>
References: <CAK6G+57yG5W+ZSShNjHMKjKPpYB-enTaWKcwC5k5wa4Oew5zXA@mail.gmail.com>

On 11/30/2018 09:53 AM, John Smith wrote:
> We have a long script of sql that we run, several thousand lines of sql. 
> If I execute the script from start to finish, somewhere in the middle of 
> it, one sql command will hang and take 2 to 3 hours. During this time, 
> "htop" shows 100% cpu usage with a postgresql process, so it appears to be 
> doing something.
>
> If I stop that command, then immediately rerun the rest of the script 
> starting from the command that "hung", the "hung" command then completes 
> in 5 seconds and the rest of the script just continues on perfectly. I can 
> interrupt the command within 30 mins of hanging, or 2 hours of hanging; 
> regardless of when I interrrupt the hung command, it always immediately 
> completes successully in < 5 seconds when I rerun the script immediately 
> after that.
>
> I have noticed this in multiple scripts, multiple commands; one was an 
> "insert into", a different script hung on a "update" and a third one would 
> hang on a "create table x as (select ... )". These are all short running 
> commands normally, and we have indexes on all the columns for the 
> appropriate "where" clauses.
>
> I can't send the sql (forbidden), but the actual command does not appear 
> to be the issue. Rerunning the same little section of sql manually which 
> includes the hung command, always takes less than a minute, but the entire 
> sql which should only take 30 minutes in total will always hang at the 
> same spot; and then interrupting it (regardless of how long it was 
> running) and rerunning immediately completes.
>
> The "hung" command does eventually finish at times after 2 to 3 hours, 
> most often we can't afford to wait for it to run since this batch of sql 
> has to run daily.
>
> Some other notes:
> - Environment is Ubuntu 16.04; postgresql version was originaly 9.5(?) but 
> we have upgraded to 11.1 using postgresql packages for ubuntu and the 
> problem has persisted across postgresql versions.
> - There are no other queries running on the postgresql server during this 
> time, and server load is idling (other than whatever psql is doing).
> - It is an amazon server, with ZFS as the files system, it has 50% disk 
> free on this storage partition that postgresql database is on.
> - We have 60 gigs of ram total, 8 cores.
> - We have run the entire script using "create unlogged table" everywhere 
> as well, no difference.
> - We have made tunings to the postgresql configuration to make it use more 
> RAM.
> - All sql commands are sent through a custom Java application; so we use 
> java + JDBC to connect to postgresql for this. The script has custom 
> commands which are interpreted by the Java app, so we can't test running 
> the exact script start to finish in psql native tools since the native 
> tools won't understand our custom sql. However the java app is very 
> simple. All individual sql commands are committed immediately after they 
> run so there is no long transaction in play here. The psql jdbc driver is 
> "postgresql-42.2.4".
> - One may suspect the custom java app; but again, htop shows postgresql 
> using 100% CPU usage on one core, so postgresql is chewing on the command, 
> doing something.
>
> I have attached our current postgresql.conf file.
>
> We're kind of pulling out our hair here, any ideas?

The (apparent) solution for us was to upgrade the JDBC driver from 42.2.1 to 
42.2.5.  Note, though, that our giant script only does DDL statements.

-- 
Angular momentum makes the world go 'round.




view thread (12+ messages)

Message-ID: <14c6e880-0a16-9bd0-42d1-da45d59a22ed@gmail.com>
Permalink:  ../14c6e880-0a16-9bd0-42d1-da45d59a22ed@gmail.com/
Also on:    postgresql.org/message-id/14c6e880-0a16-9bd0-42d1-da45d59a22ed@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: psql is hanging
  In-Reply-To: <14c6e880-0a16-9bd0-42d1-da45d59a22ed@gmail.com>
  References: <CAK6G+57yG5W+ZSShNjHMKjKPpYB-enTaWKcwC5k5wa4Oew5zXA@mail.gmail.com> <14c6e880-0a16-9bd0-42d1-da45d59a22ed@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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