Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsU50-00057I-La for pgsql-novice@arkaria.postgresql.org; Mon, 06 Jul 2020 16:34:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jsU4z-00052n-Ia for pgsql-novice@arkaria.postgresql.org; Mon, 06 Jul 2020 16:34:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsU4z-00052g-CJ for pgsql-novice@lists.postgresql.org; Mon, 06 Jul 2020 16:34:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsU4w-0008Mc-Ob for pgsql-novice@lists.postgresql.org; Mon, 06 Jul 2020 16:34:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 066GYm361380012; Mon, 6 Jul 2020 12:34:48 -0400 From: Tom Lane To: Jialun Zhang cc: pgsql-novice@lists.postgresql.org Subject: Re: What's the best practice to compare the transaction with the checkpoint? In-reply-to: References: <0bf46f63bd9f7e57a83710644a0ed4cf5f6c52f0.camel@cybertec.at> <0e86755d-57aa-9c31-31d2-f90b61456c96@verizon.net> <1377221.1594050275@sss.pgh.pa.us> Comments: In-reply-to Jialun Zhang message dated "Mon, 06 Jul 2020 12:23:31 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1380010.1594053288.1@sss.pgh.pa.us> Date: Mon, 06 Jul 2020 12:34:48 -0400 Message-ID: <1380011.1594053288@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jialun Zhang writes: > My question is that, consider such a situation (in the order of time): > 1. toast create a file for a value V; > 2. latest checkpoint; > 3. use V (here the file is read); > 4. delete the file when VACUUM deletes V; > 5. crash, then when we recover from the latest checkpoint, the file will be > accessed again but it has gone. What is "use V", and why would it be part of what is replayed in step 5? Replay generally doesn't do anything that could access potentially-deleted data, because depending on whether or not the updated page from step 4 got written out before crashing, there may or may not be any such tuple. The replay of step 4 would need to perform something like "delete the file for V if it exists, but don't complain if it does not", since we couldn't be sure which state we'll find on-disk. regards, tom lane