Re: ERROR: too many dynamic shared memory segments

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Jakub Glapa <jakub(dot)glapa(at)gmail(dot)com>, Forums postgresql <pgsql-general(at)postgresql(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ERROR: too many dynamic shared memory segments
Date: 2017-11-28 16:58:53
Message-ID: CA+Tgmob8LFw55DzH1QEREpBEA9RJ_W_amhBFCVZ6WMwUhVpOqg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tue, Nov 28, 2017 at 9:45 AM, Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>> I haven't checked whether this fixes the bug, but if it does, we can
>> avoid introducing an extra branch in BitmapHeapNext.
>
> With my test it's fixing the problem.

I tested it some more and found that, for me, it PARTIALLY fixes the
problem. I tested like this:

--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -279,7 +279,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
* parallelism than to fail outright.
*/
segsize = shm_toc_estimate(&pcxt->estimator);
- if (pcxt->nworkers > 0)
+ if (pcxt->nworkers > 0 && false)
pcxt->seg = dsm_create(segsize, DSM_CREATE_NULL_IF_MAXSEGMENTS);
if (pcxt->seg != NULL)
pcxt->toc = shm_toc_create(PARALLEL_MAGIC,

That turned out to produce more than one problem. I find that the
select_parallel test then fails like this:

ERROR: could not find key 18446744073709486082 in shm TOC at 0x10be98040

The fix for that problem seems to be:

--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -430,7 +430,8 @@ ReinitializeParallelDSM(ParallelContext *pcxt)

/* Recreate error queues. */
error_queue_space =
- shm_toc_lookup(pcxt->toc, PARALLEL_KEY_ERROR_QUEUE, false);
+ shm_toc_lookup(pcxt->toc, PARALLEL_KEY_ERROR_QUEUE, true);
+ Assert(pcxt->nworkers == 0 || error_queue_space != NULL);
for (i = 0; i < pcxt->nworkers; ++i)
{
char *start;

With that fix in place, I then hit a crash in parallel bitmap heap
scan. After applying no-pstate.patch, which I just committed and
back-patched to v10, then things look OK. I'm going to apply the fix
for the error_queue_space problem also.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ted Toth 2017-11-28 17:17:07 large numbers of inserts out of memory strategy
Previous Message David G. Johnston 2017-11-28 15:43:37 Re: [GENERAL] - Regarding Schema ROLLBACK

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-11-28 17:06:36 Re: documentation is now XML
Previous Message Peter Eisentraut 2017-11-28 16:53:50 Re: documentation is now XML