pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dainius.b <dainius.bratkauskas@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: ERROR: too many dynamic shared memory segments
Date: Thu, 20 Feb 2020 02:37:19 -0700 (MST)
Message-ID: <1582191439405-0.post@n3.nabble.com> (raw)
In-Reply-To: <CA+hUKGLyxv6+5WeMcg3+UC2HX4rtoWGzgnsx+Sfv++MJwEi-WQ@mail.gmail.com>
References: <CA+hUKGLaJbL2QCM706yiQF1W+Fm0aucqdmrRmwraf-GfPj+w9w@mail.gmail.com>
	<CAMTZZh2UL=+9VBD6SiADgN9r3HzNCZhpoPZbTFK2-1xhaXnMDw@mail.gmail.com>
	<CAMTZZh1cjdHn_QC5N=s5CPZnB8Kp8rxZu66yTuhK4t_M0O0URQ@mail.gmail.com>
	<CAMTZZh3dGq3Nk65_MEWUZMX5SDm1vt=+FhcpqdYuNr2Tj5G8eg@mail.gmail.com>
	<CA+hUKGL3TFpQDotNvuX-6PwJWaYXBqnkccR73-xAF_uaSTSt5w@mail.gmail.com>
	<CAMTZZh2d=e247vAiHTDtSYHzA-hZFXjgxSEiQaLGB9fQ6-HhGw@mail.gmail.com>
	<CA+hUKG+cfjHy63hXEOc-CRZEPcUhu9=P3gKk_W9OiXzj-dfV_g@mail.gmail.com>
	<CA+hUKGKBJjpZ=+CL-3ncT1SJWZ_Wnm-J6nSXFcNhaDnrnWh-Xg@mail.gmail.com>
	<CAMTZZh2ffaJG9FPqwm2MLysHDekiXXDwOhXdSVppxwzYg7ReXA@mail.gmail.com>
	<CA+hUKGLyxv6+5WeMcg3+UC2HX4rtoWGzgnsx+Sfv++MJwEi-WQ@mail.gmail.com>

Hello,
I also get high amount of "too many dynamic shared memory segments" errors.
Upgraded Postgres version to 12.2, but that did not help.
Server has 64GB Ram/16 CPU. Postgres params:
        "max_connections":500,
        "shared_buffers":"16GB",
        "effective_cache_size":"48GB",
        "maintenance_work_mem":"2GB",
        "checkpoint_completion_target":0.9,
        "wal_buffers":"32MB",
        "default_statistics_target":500,
        "random_page_cost":1.1,
        "effective_io_concurrency":200,
        "work_mem":"20971kB",
        "min_wal_size":"2GB",
        "max_wal_size":"8GB",
        "max_worker_processes":8,
        "max_parallel_workers_per_gather":4,
        "max_parallel_workers":8,
        "log_statement":"none"

This error happens when executing many parallel queries that have quite
complex plan:

Limit  (cost=163243.91..163250.02 rows=51 width=464) (actual
time=1224.817..1224.834 rows=31 loops=1)
  ->  Gather Merge  (cost=163243.91..165477.68 rows=18656 width=464) (actual
time=1224.815..1254.031 rows=31 loops=1)
        Workers Planned: 4
        Workers Launched: 4
        ->  Sort  (cost=162243.85..162255.51 rows=4664 width=464) (actual
time=1214.032..1214.032 rows=6 loops=5)
              Sort Key: (...)
              Sort Method: quicksort  Memory: 30kB
              Worker 0:  Sort Method: quicksort  Memory: 28kB
              Worker 1:  Sort Method: quicksort  Memory: 27kB
              Worker 2:  Sort Method: quicksort  Memory: 27kB
              Worker 3:  Sort Method: quicksort  Memory: 27kB
              ->  Parallel Hash Semi Join  (cost=41604.51..162088.25
rows=4664 width=464) (actual time=409.437..1213.922 rows=6 loops=5)
                    Hash Cond:  (...)
                    ->  Parallel Hash Join  (cost=28073.57..148289.42
rows=17880 width=464) (actual time=234.973..1165.754 rows=36930 loops=5)
                          Hash Cond:  (...)
                          ->  Parallel Hash Left Join 
(cost=20732.39..140901.30 rows=17880 width=445) (actual
time=187.482..1083.629 rows=36930 loops=5)
                                Hash Cond:  (...)
                                ->  Parallel Hash Left Join 
(cost=14850.80..134972.78 rows=17880 width=435) (actual
time=148.107..1010.915 rows=36930 loops=5)
                                      Hash Cond:  (...)
                                      ->  Parallel Hash Left Join 
(cost=8969.21..129044.25 rows=17880 width=425) (actual time=110.696..938.602
rows=36930 loops=5)
                                            Hash Cond:  (...)
                                            ->  Nested Loop 
(cost=3087.61..123115.72 rows=17880 width=411) (actual time=70.827..861.142
rows=36930 loops=5)
                                                  ->  Nested Loop 
(cost=3087.19..104038.13 rows=38340 width=263) (actual time=70.742..621.262
rows=37073 loops=5)
                                                        ->  Parallel Bitmap
Heap Scan on (...)  (cost=3086.76..73462.00 rows=39271 width=167) (actual
time=70.653..358.576 rows=37103 loops=5)
                                                              Recheck Cond: 
(...)
                                                              Filter: (...)
                                                              Rows Removed
by Filter: 42915
                                                              Heap Blocks:
exact=17872
                                                              ->  Bitmap
Index Scan on  (...) (cost=0.00..3047.49 rows=378465 width=0) (actual
time=52.331..52.331 rows=400144 loops=1)
                                                                    Index
Cond:  (...)
                                                        ->  Index Scan using 
(...)  (cost=0.43..0.78 rows=1 width=96) (actual time=0.006..0.006 rows=1
loops=185514)
                                                              Index Cond: 
(...)
                                                              Filter:  (...)
                                                              Rows Removed
by Filter: 0
                                                  ->  Index Scan using 
(...)(cost=0.43..0.50 rows=1 width=152) (actual time=0.006..0.006 rows=1
loops=185367)
                                                        Index Cond:  (...)
                                                        Filter:  (...)
                                                        Rows Removed by
Filter: 0
                                            ->  Parallel Hash 
(cost=3675.71..3675.71 rows=176471 width=18) (actual time=38.590..38.590
rows=60000 loops=5)
                                                  Buckets: 524288  Batches:
1  Memory Usage: 20640kB
                                                  ->  Parallel Seq Scan on 
(...) (cost=0.00..3675.71 rows=176471 width=18) (actual time=0.020..11.378
rows=60000 loops=5)
                                      ->  Parallel Hash 
(cost=3675.71..3675.71 rows=176471 width=18) (actual time=36.769..36.770
rows=60000 loops=5)
                                            Buckets: 524288  Batches: 1 
Memory Usage: 20608kB
                                            ->  Parallel Seq Scan on  (...) 
(cost=0.00..3675.71 rows=176471 width=18) (actual time=0.018..11.665
rows=60000 loops=5)
                                ->  Parallel Hash  (cost=3675.71..3675.71
rows=176471 width=18) (actual time=38.415..38.415 rows=60000 loops=5)
                                      Buckets: 524288  Batches: 1  Memory
Usage: 20640kB
                                      ->  Parallel Seq Scan on  (...) 
(cost=0.00..3675.71 rows=176471 width=18) (actual time=0.021..11.781
rows=60000 loops=5)
                          ->  Parallel Hash  (cost=5619.97..5619.97
rows=137697 width=27) (actual time=46.665..46.665 rows=66096 loops=5)
                                Buckets: 524288  Batches: 1  Memory Usage:
24544kB
                                ->  Parallel Seq Scan on (...) 
(cost=0.00..5619.97 rows=137697 width=27) (actual time=0.024..16.629
rows=66096 loops=5)
                    ->  Parallel Hash  (cost=12679.65..12679.65 rows=68103
width=4) (actual time=28.674..28.674 rows=41176 loops=5)
                          Buckets: 262144  Batches: 1  Memory Usage: 10176kB
                          ->  Parallel Index Only Scan using (...) 
(cost=0.57..12679.65 rows=68103 width=4) (actual time=0.048..15.443
rows=41176 loops=5)
                                Index Cond: ()
                                Heap Fetches: 205881
Planning Time: 6.941 ms
Execution Time: 1254.251 ms

So to avoid getting these errors the only solution is to decrease work_mem
or turn off paralelism? Because I hoped that in such case it would take
longer time to complete the queries but instead I get high amount of queries
just crashing.


Thomas Munro-5 wrote
> On Fri, Jan 31, 2020 at 11:05 PM Nicola Contu &lt;

> nicola.contu@

> &gt; wrote:
>> Do you still recommend to increase max_conn?
> 
> Yes, as a workaround of last resort.  The best thing would be to
> figure out why you are hitting the segment limit, and see if there is
> something we could tune to fix that. If you EXPLAIN your queries, do
> you see plans that have a lot of "Gather" nodes in them, perhaps
> involving many partitions?  Or are you running a lot of parallel
> queries at the same time?  Or are you running queries that do very,
> very large parallel hash joins?  Or something else?





--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html





view thread (35+ messages)

Message-ID: <1582191439405-0.post@n3.nabble.com>
Permalink:  ../1582191439405-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1582191439405-0.post@n3.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: dainius.bratkauskas@gmail.com
  Subject: Re: ERROR: too many dynamic shared memory segments
  In-Reply-To: <1582191439405-0.post@n3.nabble.com>
  References: <CA+hUKGLaJbL2QCM706yiQF1W+Fm0aucqdmrRmwraf-GfPj+w9w@mail.gmail.com> <CAMTZZh2UL=+9VBD6SiADgN9r3HzNCZhpoPZbTFK2-1xhaXnMDw@mail.gmail.com> <CAMTZZh1cjdHn_QC5N=s5CPZnB8Kp8rxZu66yTuhK4t_M0O0URQ@mail.gmail.com> <CAMTZZh3dGq3Nk65_MEWUZMX5SDm1vt=+FhcpqdYuNr2Tj5G8eg@mail.gmail.com> <CA+hUKGL3TFpQDotNvuX-6PwJWaYXBqnkccR73-xAF_uaSTSt5w@mail.gmail.com> <CAMTZZh2d=e247vAiHTDtSYHzA-hZFXjgxSEiQaLGB9fQ6-HhGw@mail.gmail.com> <CA+hUKG+cfjHy63hXEOc-CRZEPcUhu9=P3gKk_W9OiXzj-dfV_g@mail.gmail.com> <CA+hUKGKBJjpZ=+CL-3ncT1SJWZ_Wnm-J6nSXFcNhaDnrnWh-Xg@mail.gmail.com> <CAMTZZh2ffaJG9FPqwm2MLysHDekiXXDwOhXdSVppxwzYg7ReXA@mail.gmail.com> <CA+hUKGLyxv6+5WeMcg3+UC2HX4rtoWGzgnsx+Sfv++MJwEi-WQ@mail.gmail.com> <1582191439405-0.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox