Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hG5AQ-00069r-MA for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Apr 2019 17:13:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hG5AO-0005CD-Vi for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Apr 2019 17:13:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hG5AO-0005C6-JW for pgsql-hackers@lists.postgresql.org; Mon, 15 Apr 2019 17:13:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hG5AL-0001Al-9J for pgsql-hackers@postgresql.org; Mon, 15 Apr 2019 17:13:10 +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 x3FHD1RY016816; Mon, 15 Apr 2019 13:13:01 -0400 From: Tom Lane To: Masahiko Sawada cc: Robert Haas , Kyotaro HORIGUCHI , "Bossart, Nathan" , Alvaro Herrera , PostgreSQL-development Subject: Re: New vacuum option to do only freezing In-reply-to: References: <20190403.131702.71087088.horiguchi.kyotaro@lab.ntt.co.jp> <20190404.091743.76975665.horiguchi.kyotaro@lab.ntt.co.jp> <15751.1555256860@sss.pgh.pa.us> Comments: In-reply-to Masahiko Sawada message dated "Mon, 15 Apr 2019 15:07:24 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16813.1555348381.1@sss.pgh.pa.us> Date: Mon, 15 Apr 2019 13:13:01 -0400 Message-ID: <16814.1555348381@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Masahiko Sawada writes: >> Ugh, I think the assertion is right but the above condition is >> completely wrong. We should increment nleft_dead_tuples when index >> cleanup is *not* enabled. > Here is a draft patch to fix this issue. So the real issue here, I fear, is that we've got no consistent testing of the whole case block for HEAPTUPLE_DEAD, as you can easily confirm by checking the code coverage report at https://coverage.postgresql.org/src/backend/access/heap/vacuumlazy.c.gcov.html This is perhaps unsurprising, given the code comment that points out that we can only reach that block if the tuple's state changed since heap_page_prune() a few lines above. Still, it means that this patch hasn't been tested in that scenario, until we were lucky enough for a slow buildfarm machine like topminnow to hit it. What's more, because that block is the only way for "tupgone" to be set, we also don't reach the "if (tupgone)" block at lines 1183ff. And I think this patch has probably broken that, too. Surely, if we are not going to remove the tuple, we should not increment tups_vacuumed? And maybe we have to freeze it instead? How is it that we can, or should, treat this situation as different from a dead-but-not-removable tuple? I have a very strong feeling that this patch was not fully baked. BTW, I can reproduce the crash fairly easily (within a few cycles of the regression tests) by (a) inserting pg_usleep(10000) after the heap_page_prune call, and (b) making autovacuum much more aggressive. regards, tom lane