BUG #19105: Parallel Hash Join crash when work_mem is small

Started by PG Bug reporting form5 months ago5 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 19105
Logged by: Nagesh Ka
Email address: nageshdbaa@gmail.com
PostgreSQL version: 16.2
Operating system: Ubuntu 22.04 x86_64
Description:

PostgreSQL version: 16.2 (Ubuntu 22.04 x86_64)
Compiled by gcc (Ubuntu 11.4.0)
work_mem = 1MB
max_parallel_workers_per_gather = 4

CREATE TABLE t1 AS SELECT i, md5(i::text) AS txt FROM
generate_series(1,1000000) i;
CREATE TABLE t2 AS SELECT i, md5(i::text) AS txt FROM
generate_series(1,1000000) i;

SET work_mem = '1MB';
SET max_parallel_workers_per_gather = 4;

SELECT t1.i, count(*)
FROM t1 JOIN t2 USING(i)
GROUP BY t1.i;

-->Expected Result

Query should complete successfully and return a count for each key.

-->Observed Result

Server terminates with:

ERROR: could not attach to dynamic shared area
DETAIL: invalid dsa_handle

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: BUG #19105: Parallel Hash Join crash when work_mem is small

PG Bug reporting form <noreply@postgresql.org> writes:

PostgreSQL version: 16.2

Server terminates with:

ERROR: could not attach to dynamic shared area
DETAIL: invalid dsa_handle

I could not reproduce this problem with current sources
(either master or v16 branch tip). 16.2 is pretty old,
so maybe an update will fix it for you.

regards, tom lane

#3Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Tom Lane (#2)
Re: BUG #19105: Parallel Hash Join crash when work_mem is small

On 11/9/25 16:47, Tom Lane wrote:

PG Bug reporting form <noreply@postgresql.org> writes:

PostgreSQL version: 16.2

Server terminates with:

ERROR: could not attach to dynamic shared area
DETAIL: invalid dsa_handle

I could not reproduce this problem with current sources
(either master or v16 branch tip). 16.2 is pretty old,
so maybe an update will fix it for you.

FWIW I couldn't reproduce it on 16.2 either, even after forcing it to
actually do parallel hash join (the posted instructions were not enough
to make that happen on my system).

Presumably there's some additional detail making it fail, but there are
too many options to guess. Maybe it's some kernel limit, something in
ubuntu 22.04, or something else.

It's interesting the report claims this happens only "when work_mem is
small". I wonder if that happens simply because the plan changes.

regards

--
Tomas Vondra

#4Thomas Munro
thomas.munro@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #19105: Parallel Hash Join crash when work_mem is small

On Mon, Nov 10, 2025 at 4:23 AM PG Bug reporting form
<noreply@postgresql.org> wrote:

ERROR: could not attach to dynamic shared area
DETAIL: invalid dsa_handle

ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("could not attach to dynamic shared area")));

Where do we emit that DETAIL message?

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thomas Munro (#4)
Re: BUG #19105: Parallel Hash Join crash when work_mem is small

Thomas Munro <thomas.munro@gmail.com> writes:

On Mon, Nov 10, 2025 at 4:23 AM PG Bug reporting form
<noreply@postgresql.org> wrote:

ERROR: could not attach to dynamic shared area
DETAIL: invalid dsa_handle

ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("could not attach to dynamic shared area")));

Where do we emit that DETAIL message?

I'd not picked up on that point, but you're right: we don't emit any
such DETAIL anywhere, not in current and not in 16.2 either. Must
be a locally-modified tree, or maybe just a copy-paste error in the
report?

regards, tom lane