Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zim8M-00024m-3h for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2015 16:27:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zim8K-0001iX-Kj for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2015 16:27:32 +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) (envelope-from ) id 1Zim8I-0001gv-NG for pgsql-hackers@postgresql.org; Sun, 04 Oct 2015 16:27:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zim8B-0000sB-As for pgsql-hackers@postgresql.org; Sun, 04 Oct 2015 16:27:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t94GRFQW032386; Sun, 4 Oct 2015 12:27:15 -0400 From: Tom Lane To: Peter Geoghegan cc: Jim Nasby , Pg Hackers Subject: Re: Less than ideal error reporting in pg_stat_statements In-reply-to: References: <5601D354.5000703@BlueTreble.com> <15898.1442965225@sss.pgh.pa.us> <5913.1443822154@sss.pgh.pa.us> <9935.1443828452@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Sat, 03 Oct 2015 11:37:35 -0700" Date: Sun, 04 Oct 2015 12:27:15 -0400 Message-ID: <32385.1443976035@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Peter Geoghegan writes: > Attached, revised patch deals with the issues around removing the > query text file when garbage collection encounters trouble. There is > no reason to be optimistic about any error within gc_qtexts() not > recurring during a future garbage collection. OOM might be an > exception, but probably not, since gc_qtexts() is reached when a new > entry is created with a new query text, which in general makes OOM > progressively more likely. Hm. I'm unconvinced by the aspects of this that involve using mean_query_len as a filter on which texts will be accepted. While that's not necessarily bad in the abstract, there are way too many implementation artifacts here that will result in random-seeming decisions about whether to normalize. For instance: * mean_query_len only gets recomputed in entry_dealloc(), which is only run if we exceed pgss_max, and gc_qtexts(), which is only run if we decide the query texts file is more than 50% bloat. So there could be quite a long startup transient before the value gets off its initialization minimum, and I'm suspicious that there might be plausible use-cases where it never does. So it's not so much "restrict to a multiple of the mean query len" as "restrict to some number that might once upon a time have had some relation to the mean query len, or maybe not". * One could expect that after changing mean_query_len, the population of query texts would change character as a result of the filter behavior changing, so that convergence to stable behavior over the long haul is not exactly self-evident. * As you've got it here, entry_dealloc() and gc_qtexts() don't compute mean_query_len the same way, because only one of them discriminates against sticky entries. So the value would bounce about rather randomly based on which one had run last. * I'm not exactly convinced that sticky entries should be ignored for this purpose anyway. Taking a step back, ISTM the real issue you're fighting here is lots of orphaned sticky entries, but the patch doesn't do anything directly to fix that problem. I wonder if we should do something like making entry_dealloc() and/or gc_qtexts() aggressively remove sticky entries, or at least those with "large" texts. I think the aspects of this patch that are reasonably uncontroversial are increasing the allowed malloc attempt size in gc_qtexts, flushing the query text file on malloc failure, fixing the missing cleanup steps after a gc failure, and making entry_dealloc's recomputation of mean_query_len sane (which I'll define for the moment as "the same as gc_qtexts would get"). Since we're hard against a release deadline, I propose to commit just those changes, and we can consider the idea of a query size filter and/or redefining mean_query_len at leisure. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers