pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: steven.winfield@cantabcapital.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14473: Parallel query aborts with too many connections
Date: Thu, 22 Dec 2016 11:13:45 +0000
Message-ID: <20161222111345.25620.8603@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14473
Logged by:          Steven Winfield
Email address:      steven.winfield@cantabcapital.com
PostgreSQL version: 9.6.1
Operating system:   RHEL 7.3
Description:        

Let's say a user is using all but two or three of their allowed connections
(set with ALTER USER name CONNECTION LIMIT n).

Now if they attempt to execute a query that would be executed in parallel by
many (say 8) workers, such as a count(*) of a large table, then the users
connection limit can be reached and the query is aborted:

mydatabase=> select count(*) from large_table;
ERROR:  too many connections for role "myname"
CONTEXT:  parallel worker

...even though the query could have been successfully executed with fewer
workers (as I checked by locally setting max_parallel_workers_per_gather to
0).

This is surprising, because in other circumstances the query _can_ proceed
with fewer workers than planned - e.g. when the max_worker_processes limit
has been hit.

From the docs:
(https://www.postgresql.org/docs/9.6/static/how-parallel-query-works.html)

"Every background worker process which is successfully started for a given
parallel query will execute the portion of the plan which is a descendent of
the Gather node"

...implying (at least to me) that workers may not start successfully, but
this is handled gracefully.

I couldn't find anything in the docs about the relationship between
max_parallel_workers_per_gather and a user's connection limit, nor that the
connection could be blown and that queries could be aborted.

Thanks,
Steve.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (6+ messages)  latest in thread

Message-ID: <20161222111345.25620.8603@wrigleys.postgresql.org>
Permalink:  ../20161222111345.25620.8603@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20161222111345.25620.8603@wrigleys.postgresql.org

 · 

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-bugs@postgresql.org
  Cc: steven.winfield@cantabcapital.com
  Subject: Re: BUG #14473: Parallel query aborts with too many connections
  In-Reply-To: <20161222111345.25620.8603@wrigleys.postgresql.org>
  References: <20161222111345.25620.8603@wrigleys.postgresql.org>

* 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