Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bguXg-00048d-Ff for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Sep 2016 14:06:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bguXe-0003Ou-JX for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Sep 2016 14:06:30 +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.84_2) (envelope-from ) id 1bguWH-0001n5-L0 for pgsql-hackers@postgresql.org; Mon, 05 Sep 2016 14:05:05 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bguWD-0005mQ-U0 for pgsql-hackers@postgresql.org; Mon, 05 Sep 2016 14:05:04 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 3AEE821C27B2; Mon, 5 Sep 2016 17:05:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8akooczPPgRn; Mon, 5 Sep 2016 17:05:01 +0300 (MSK) Received: from [192.168.27.190] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 0F42F21C27B1; Mon, 5 Sep 2016 17:05:01 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1473084301; bh=Y71wPhBBSeft2gmEolWrrcCaJ9ovs+R6lBU2bBMooN8=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=fVMh2XiHj5Q/8eukvUBG42d1yECqb+Lj6yMXGwzbbAd7BzGRsyGoEllFMoALDtovp bEEanmuvvc2RFRpOfyIpq4gI8zDYYoqicR4tbAtbY3ulwCGshZfrVojMdbhDo8WjF+ 5veqNWhUakmlLkIZmCo7NnhYfjyfMidXW7PselWs= Subject: Re: Fun fact about autovacuum and orphan temp tables To: Alvaro Herrera References: <20160905133440.GA671130@alvherre.pgsql> Cc: pgsql-hackers@postgresql.org From: Grigory Smolkin Message-ID: <5b48a2e8-571a-d24f-6a4a-cd5744e6f1dc@postgrespro.ru> Date: Mon, 5 Sep 2016 17:05:00 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20160905133440.GA671130@alvherre.pgsql> Content-Type: multipart/alternative; boundary="------------CACD60254A772A7CCFD55BED" X-Pg-Spam-Score: -3.7 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------CACD60254A772A7CCFD55BED Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 09/05/2016 04:34 PM, Alvaro Herrera wrote: > Grigory Smolkin wrote: > >> Funny part is that it never drops them. So when backend is finally >> terminated, it tries to drop them and fails with error: >> >> FATAL: out of shared memory >> HINT: You might need to increase max_locks_per_transaction >> >> If I understand that rigth, we are trying to drop all these temp tables in >> one transaction and running out of locks to do so. > Hmm, yeah, I suppose it does that, and it does seem pretty inconvenient. > It is certainly pointless to hold onto these locks for temp tables. I > wonder how ugly would be to fix this problem ... > Thank you for your interest in this problem. I dont think this is a source of problem. Ugly fix here would only force backend to terminate properly. It will not help at all in cause of server crash or power outage. We need a way to tell autovacuum, that we don`t need orphan temp tables, so they can be removed using existing routine. The least invasive solution would be to have a guc, something like 'keep_orphan_temp_tables' with boolean value. Which would determine a autovacuum worker policy toward encountered orphan temp tables. -- Grigory Smolkin Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------CACD60254A772A7CCFD55BED Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 7bit
On 09/05/2016 04:34 PM, Alvaro Herrera wrote:
Grigory Smolkin wrote:

Funny part is that it never drops them. So when backend is finally
terminated, it tries to drop them and fails with error:

FATAL:  out of shared memory
HINT:  You might need to increase max_locks_per_transaction

If I understand that rigth, we are trying to drop all these temp tables in
one transaction and running out of locks to do so.
Hmm, yeah, I suppose it does that, and it does seem pretty inconvenient.
It is certainly pointless to hold onto these locks for temp tables.  I
wonder how ugly would be to fix this problem ...


Thank you for your interest in this problem.
I dont think this is a source of problem. Ugly fix here would only force backend to terminate properly.
It will not help at all in cause of server crash or power outage.
We need a way to tell autovacuum, that we don`t need orphan temp tables, so they can be removed using existing routine.

The least invasive solution would be to have a guc, something like 'keep_orphan_temp_tables' with boolean value.
Which would determine a autovacuum worker policy toward encountered orphan temp tables.

-- 
Grigory Smolkin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
--------------CACD60254A772A7CCFD55BED--