| From: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> | 
|---|---|
| To: | Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> | 
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com> | 
| Subject: | Re: crashes due to setting max_parallel_workers=0 | 
| Date: | 2017-03-25 08:51:51 | 
| Message-ID: | CAKJS1f-jnPUKyeF5OGJPNDtkkqMGUOcK+Yn6qjPzP4bTU04WXg@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On 25 March 2017 at 13:10, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> wrote:
> while working on a patch I ran into some crashes that seem to be caused by
> inconsistent handling of max_parallel_workers - queries still seem to be
> planned with parallel plans enabled, but then crash at execution.
>
> The attached script reproduces the issue on a simple query, causing crashed
> in GatherMerge, but I assume the issue is more general.
I had a look at this and found a bunch of off by 1 errors in the code.
I've attached a couple of patches, one is the minimal fix, and one
more complete one.
In the more complete one I ended up ditching the
GatherMergeState->nreaders altogether. It was always the same as
nworkers_launched anyway, so I saw no point in it.
Here I've attempted to make the code a bit more understandable, to
prevent further confusion about how many elements are in each array.
Probably there's more that can be done here. I see GatherState has
nreaders too, but I've not looked into the detail of if it suffers
from the same weirdness of nreaders always matching nworkers_launched.
-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services
| Attachment | Content-Type | Size | 
|---|---|---|
| gather_merge_minimal_fix.patch | application/octet-stream | 1.1 KB | 
| gather_merge_fix.patch | application/octet-stream | 6.6 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Munro | 2017-03-25 08:55:21 | Re: Problem in Parallel Bitmap Heap Scan? | 
| Previous Message | Kuntal Ghosh | 2017-03-25 08:26:04 | Re: exposing wait events for non-backends (was: Tracking wait event for latches) |