BUG #19363: PostgreSQL shared memory exhaustion during query execution involving views and parallel workers - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19363: PostgreSQL shared memory exhaustion during query execution involving views and parallel workers
Date
Msg-id 19363-8dd32fc7600a1153@postgresql.org
Whole thread Raw
Responses Re: BUG #19363: PostgreSQL shared memory exhaustion during query execution involving views and parallel workers
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19363
Logged by:          Jinhui Lai
Email address:      jinhui.lai@qq.com
PostgreSQL version: 18.1
Operating system:   ubuntu 22.04
Description:

Hi, PostgreSQL developers:

Thanks for reading my report. I may find a bug. You can reproduce it as
follows:

CREATE TABLE t0(c0 REAL);
CREATE TABLE t1(c0 REAL);
CREATE TABLE t2(c0 REAL) WITH (parallel_workers=1);
CREATE TABLE t3(c0 REAL) WITH (parallel_workers=2);
CREATE VIEW v0(c0, c1, c2) AS (SELECT t0.c0, t1.c0, t2.c0 FROM t0, t1, t2);
SELECT t3.c0 FROM t3 WHERE NOT EXISTS (SELECT 1 FROM v0 WHERE t3.c0 =
v0.c0);
ERROR:  could not resize shared memory segment "/PostgreSQL.3961899888" to
33624064 bytes: No space left on device

When executing a query with a NOT EXISTS subquery referencing a view that
joins multiple tables, PostgreSQL fails with a shared memory allocation
error ("could not resize shared memory segment ... No space left on
device"). The issue appears to be related to parallel query execution, as it
occurs when one of the underlying tables (t3) has parallel_workers set to 2,
while another table (t2) has parallel_workers set to 1. The problem
manifests specifically during the query's execution phase, where the planner
attempts to allocate shared memory for parallel workers, suggesting a
possible resource leak or inadequate cleanup of shared memory segments when
parallel queries involve views. The error persists despite sufficient
available system memory, indicating an internal PostgreSQL resource
management issue rather than a system-level memory constraint.

Best regards,
Jinhui Lai


pgsql-bugs by date:

Previous
From: "G. Sl"
Date:
Subject: Re: Standby server with cascade logical replication could not be properly stopped under load
Next
From: PG Bug reporting form
Date:
Subject: BUG #19364: Repository not updating