pgsql: Fall back to serializing when parallel apply runs out of DSM seg

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fall back to serializing when parallel apply runs out of DSM seg
Date: 2026-11-18 18:30:45
Message-ID: E1xTkQe-00000000HDF-3Ee0@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fall back to serializing when parallel apply runs out of DSM segments.

Commit 216a784829c made the leader apply worker serialize a streamed
transaction to a file if it fails to set up the shared memory for a
parallel apply worker. However, it called dsm_create() without
DSM_CREATE_NULL_IF_MAXSEGMENTS, so running out of DSM segments raised
an ERROR instead. The leader apply worker then exited and failed again
at the same STREAM START after restarting, so replication made no
progress until segments were freed.

Fix by passing DSM_CREATE_NULL_IF_MAXSEGMENTS, as parallel query does.

Backpatch to v16, where parallel apply was introduced.

Author: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
Reviewed-by: Zhijie Hou <houzhijie22(at)gmail(dot)com>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Discussion: https://postgr.es/m/CA+fm-RMyb6EoMuk+a4_hZou9cdTHfB6mj1UV-7yb_YuTWLug1g@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5aafc5cb6ee2747cf76fa60804ca248c833039f4

Modified Files
--------------
src/backend/replication/logical/applyparallelworker.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Melanie Plageman 2026-11-18 18:46:58 pgsql: Fix pgstattuple test with forced parallel queries
Previous Message Masahiko Sawada 2026-11-18 18:30:41 pgsql: Fall back to serializing when parallel apply runs out of DSM seg