Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id C25E71337B5D for ; Mon, 25 Oct 2010 16:57:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 83644-09 for ; Mon, 25 Oct 2010 19:57:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id D8DB81337B4E for ; Mon, 25 Oct 2010 16:57:12 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9PJvARa004233; Mon, 25 Oct 2010 15:57:10 -0400 (EDT) To: Nick cc: Kevin Grittner , pgsql-admin@postgresql.org, Alvaro Herrera Subject: Re: autovacuum launcher process eating up 17G+ of ram? In-reply-to: References: <4CC071670200002500036C8A@gw.wicourts.gov> <4CC18EF60200002500036CF3@gw.wicourts.gov> Comments: In-reply-to Nick message dated "Mon, 25 Oct 2010 10:01:28 -0700" Date: Mon, 25 Oct 2010 15:57:10 -0400 Message-ID: <4232.1288036630@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/181 X-Sequence-Number: 35922 Nick writes: > It seems like the problem is a function of how many databases there are. Yeah, I can reproduce this in HEAD. Create a hundred or so databases, and make sure there's a stats table entry for each, eg create database d0; \c d0 create table t1 as select generate_series(1,100000) x; create database d1; \c d1 create table t1 as select generate_series(1,100000) x; create database d2; \c d2 create table t1 as select generate_series(1,100000) x; ... Set autovacuum_naptime to 1sec, and watch it bloat. (It bloats faster once it's run through the databases once and isn't mostly waiting for children.) It looks to me like the problem is that get_database_list() intentionally pushes its result into a long-lived context, and then the result is never cleaned up. It doesn't help any that it does a lot of leaky things like heap_beginscan with CurrentMemoryContext totally unnecessarily pointing at the long-lived context. I'm not sure what the intent was here, but it's pretty broken as-is. Alvaro, what did you have in mind? Should this be using a less long-lived context, or do we need code to free an avw_dbase list? regards, tom lane