Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bupvy-0003n8-5L for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Oct 2016 00:01:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bupvx-0001sH-LC for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Oct 2016 00:01:09 +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 1bupvv-0001rN-Ou for pgsql-hackers@postgresql.org; Fri, 14 Oct 2016 00:01:07 +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_2) (envelope-from ) id 1bupvs-00009c-1F for pgsql-hackers@postgresql.org; Fri, 14 Oct 2016 00:01:06 +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 u9E00xmP008338; Thu, 13 Oct 2016 20:00:59 -0400 From: Tom Lane To: Stas Kelvich cc: Pg Hackers Subject: Re: Stats sender and 2pc minor problem In-reply-to: References: Comments: In-reply-to Stas Kelvich message dated "Thu, 13 Oct 2016 15:36:59 +0300" Date: Thu, 13 Oct 2016 20:00:59 -0400 Message-ID: <8337.1476403259@sss.pgh.pa.us> X-Pg-Spam-Score: -2.3 (--) 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 Stas Kelvich writes: > Statistics sender logic during usual commit and two-phase commit do not > strictly matches each other and that leads to delta_live_tuples added to > n_live_tup in case of truncate in two phase commit. Yeah, that code says it's supposed to match AtEOXact_PgStat, but it doesn't. I pushed this, but without the regression test case, which would have failed outright in any test run with max_prepared_transactions = 0. Timing sensitivity is another problem. In the commit that created this discrepancy, d42358efb, Alvaro had tried to add regression coverage for this area, but we ended up backing it out because it failed too often in the buildfarm. TBH, now that I look at it, I think that d42358efb was fundamentally wrong and this patch is just continuing down the same wrong path. Having the stats collector respond to a TRUNCATE like this cannot work reliably, because the "it got truncated" flag will arrive at the stats collector asynchronously, perhaps quite some time later than the truncate occurred. When that happens, we may throw away live/dead tuple count updates from transactions that actually happened after the truncate but chanced to report first. I wonder if we could make that better by making the stats collector track stats by relfilenode rather than table OID. It'd be a pretty major logic change, though, to serve a corner case. 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