Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKt7u-0002MM-4u for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2017 21:45:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKt7t-0001hq-Am for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2017 21:45:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eKt7t-0001hg-4L for pgsql-hackers@lists.postgresql.org; Fri, 01 Dec 2017 21:45:41 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eKt7q-0008AR-0X for pgsql-hackers@postgresql.org; Fri, 01 Dec 2017 21:45:40 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 5B36120A4D; Fri, 1 Dec 2017 16:45:36 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Fri, 01 Dec 2017 16:45:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=zNBKWAOdc0kIjHGyMmTgq8ZZZO1wt wvFCYkxyZiPy9Y=; b=rzIE/RO1zFM53RGgGVeEh2qGmOTH6VGXFmCo5YbVWjSok 8Xe5zWmSA72cHYTuy4dKLz1nWT10jWhITMp8CEBt+M/mCKFnYs9qqTyqoUP8AHdt 4h9aXpYuv5RmbvFVtYBNVLfWhP6t+6bRIv9c1IcoscQ8ya2tDzgv7YO/AvnY4zec vCWzg0qbvuyL1Ke+Er4+lEf6PjzuqvIM+r565FynwzxiFyEEUSzW8bYUh+w6Sl4W KvU1N0R6DYKHJtmFOa//zR88EvU52SOKaWwBev9gpjfxL9U/oRHOIDLJ66jqM9Ib MO7Mi71k0sy+/2yIe3Y1+8SJP0f2FY9S2aI65zvqw== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 06F2724536; Fri, 1 Dec 2017 16:45:36 -0500 (EST) Date: Fri, 1 Dec 2017 13:45:34 -0800 From: Andres Freund To: Tom Lane Cc: Robert Haas , Michael Paquier , Kyotaro HORIGUCHI , David Steele , Jim Nasby , Craig Ringer , PostgreSQL mailing lists Subject: Re: Protect syscache from bloating with negative cache entries Message-ID: <20171201214534.dfp2sd427puislll@alap3.anarazel.de> References: <20171031.184622.92520047.horiguchi.kyotaro@lab.ntt.co.jp> <84820.1512015443@sss.pgh.pa.us> <85587.1512101829@sss.pgh.pa.us> <20171201213113.z4gbol66ipvg5b4o@alap3.anarazel.de> <3544.1512164423@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3544.1512164423@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2017-12-01 16:40:23 -0500, Tom Lane wrote: > Andres Freund writes: > > On 2017-12-01 16:20:44 -0500, Robert Haas wrote: > >> Well, yeah, that would be insane. But I think even something very > >> rough could work well enough. I think our goal should be to eliminate > >> cache entries that are have gone unused for many *minutes*, and > >> there's no urgency about getting it to any sort of exact value. For > >> non-idle backends, using the most recent statement start time as a > >> proxy would probably be plenty good enough. Idle backends might need > >> a bit more thought. > > > Our timer framework is flexible enough that we can install a > > once-a-minute timer without much overhead. That timer could increment a > > 'cache generation' integer. Upon cache access we write the current > > generation into relcache / syscache (and potentially also plancache?) > > entries. Not entirely free, but cheap enough. In those once-a-minute > > passes entries that haven't been touched in X cycles get pruned. > > I have no faith in either of these proposals, because they both assume > that the problem only arises over the course of many minutes. In the > recent complaint about pg_dump causing relcache bloat, it probably does > not take nearly that long for the bloat to occur. To me that's a bit of a different problem than what I was discussing here. It also actually doesn't seem that hard - if your caches are growing fast, you'll continually get hash-resizing of the various. Adding cache-pruning to the resizing code doesn't seem hard, and wouldn't add meaningful overhead. Greetings, Andres Freund