Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fgWY9-000230-7f for pgsql-admin@arkaria.postgresql.org; Fri, 20 Jul 2018 14:38:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fgWY7-0007Ye-O9 for pgsql-admin@arkaria.postgresql.org; Fri, 20 Jul 2018 14:38:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fgWY7-0007YP-7N for pgsql-admin@lists.postgresql.org; Fri, 20 Jul 2018 14:38:27 +0000 Received: from smtp212-pc.aruba.it ([62.149.157.212] helo=smtpg-pc.aruba.it) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fgWY3-00042m-Cp for pgsql-admin@lists.postgresql.org; Fri, 20 Jul 2018 14:38:25 +0000 Received: from DT02 ([93.63.211.242]) by smtpcm2-pc.aruba.it with bizsmtp id D2eM1y0025ELnP9012eMo5; Fri, 20 Jul 2018 16:38:21 +0200 From: "Alfonso Moscato" To: "'Tom Lane'" Cc: References: <00a601d4201a$e2291a10$a67b4e30$@merqurio.it> <17662.1532096551@sss.pgh.pa.us> In-Reply-To: <17662.1532096551@sss.pgh.pa.us> Subject: R: repeated out of shared memory error - not related to max_locks_per_transaction Date: Fri, 20 Jul 2018 16:38:21 +0200 Message-ID: <016801d42037$4f5d4630$ee17d290$@merqurio.it> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJyTRksqbTjmmAqDGBi/OX9BtlRvgJEoSREo0msSmA= Content-Language: it DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aruba.it; s=a1; t=1532097501; bh=LcA3i7cG05DUY7VEhGe8yHwKNaFrJ2WXB0XBndBTK6o=; h=From:To:Subject:Date:MIME-Version:Content-Type; b=l0RLCcB4ULQZZwCN7ubYFyaQXQJzjq9Cdlj2iXN96EYr+9SF3gozncExBTbungNtB c09lVhKYWCEf46Cb883EMFTrtfHms0SMQK/w4jhYOegZL0MY9CLKCBBiHIIHh83kJr KyEHmPcy4rq/QzAZURKf7yqpIqAiVdfcKqtfY3rwrWBJWua+NXfICeieYgcu43kXAJ 0cIpn9AvpmDByrF5tlsze+bVczB44yJ15JbDccOU6I5kAs0wZZi+E3ygaq5OzHyoUF hVfwJJsk4SRlxKclcaoYAxGDFoAeZgTsJkW432Ipq4oZsEeo7w6LoMjLH4JcxQBx83 Ouz6Dfk0B0D6A== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Tom, i agree with you, there is something allocating and not releasing = memory. This because the error starts after many hours. I have some extensions installed, namely: "plpgsql" "mysql_fdw" "multicorn" "pg_cron" "tds_fdw" "pg_stat_statements" I have 200 connections and 384 max_locks_per_transaction in = postgresql.conf, that brings the ttal number og locks to 76.800. I have surely very big queries, some with more than 50 tables, = subqueries, and so on. As for your questions: 1) lock table entries needed: we check regularly the number of locks. It doesn't seem they usually exceed some hundreds. I will create a cron to check them regularly. 2) We have some very complex functions, touching many tables and = returning 1/2 million rows 3) we don't use any kind of personalised locks. The db is set to read_committed isolation level. Just two question: How could I understand which extension is consuming shared memory? I = can't figure how. Is there some way other than increasing max_locks_per_transaction to = drive postgres to allocate more shared memory? -----Messaggio originale----- Da: Tom Lane =20 Inviato: venerd=EC 20 luglio 2018 16:23 A: Alfonso Moscato Cc: pgsql-admin@lists.postgresql.org Oggetto: Re: repeated out of shared memory error - not related to max_locks_per_transaction "Alfonso Moscato" writes: > We are getting crazy with "out of shared memory" errors, and we can't=20 > figure the reason. I don't think any of the advice posted so far has anything to do with = your problem --- certainly, fooling with work_mem is unrelated. PG shared = memory is a fixed-size arena (for any one setting of shared_buffers, max_connections, max_locks_per_transaction, and a couple other = variables) and most of its contents are pre-allocated at postmaster start. What = you are describing sounds like a long-term leak of additional, post-startup shmem allocations, eventually running out of the available slop in the = shmem arena. work_mem, and other user-visible knobs, have nothing to do with = this because those control allocations in process private memory not shmem. I'm pretty sure that the *only* post-startup shmem allocations in the = core code are for lock table entries. However, if you're running any = non-core extensions, it's possible that one of them does such allocations and has = a logic error that results in a shmem leak. As an amelioration measure, you could raise max_locks_per_transaction, = which will increase the arena size without actually eating any additional = space immediately at startup. That might not cure the problem, but at least = it would increase the interval at which you have to restart the server. As for real solutions, I'd first look harder at the question of how many lock table entries you need. The fact that you only see a few dozen = active entries when you look (after a failure) doesn't prove a thing about what = the max transient requirement is. Do you have any applications that touch a whole lot of tables in a single transaction? Are you using any = user-defined (advisory) locks, and if so what's the usage pattern like for those? The "bug in an extension" theory also needs investigation. regards, tom lane