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 1nhAVL-0003sI-TX for pgsql-general@arkaria.postgresql.org; Wed, 20 Apr 2022 13:36:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nhAVK-0004xr-MQ for pgsql-general@arkaria.postgresql.org; Wed, 20 Apr 2022 13:36:22 +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 1nhAVK-0004xh-Bn for pgsql-general@lists.postgresql.org; Wed, 20 Apr 2022 13:36:22 +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 1nhAVF-0001sd-2T for pgsql-general@lists.postgresql.org; Wed, 20 Apr 2022 13:36:21 +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 23KDaE3j2781109; Wed, 20 Apr 2022 09:36:14 -0400 From: Tom Lane To: Huan Ruan cc: pgsql-general@lists.postgresql.org Subject: Re: PITR and Temp Tables In-reply-to: References: Comments: In-reply-to Huan Ruan message dated "Wed, 20 Apr 2022 22:17:32 +1000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2781107.1650461774.1@sss.pgh.pa.us> Date: Wed, 20 Apr 2022 09:36:14 -0400 Message-ID: <2781108.1650461774@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Huan Ruan writes: > Let's say at T0 a database has N session based temp tables. They would have > corresponding records in the catalog tables like pg_class and pg_attribute > that are visible to other sessions. > At T1, I do a PITR to T0. That recovered database should not have those > temp tables because the sessions they were created in are not present. My > question is what events trigger the deletion of those temp tables' catalog > records (e.g. pg_class and pg_attribute etc.) in the recovered database? Those records will still be there in the catalogs, yes. Cleaning out the contents of a temporary schema is not the responsibility of the WAL/recovery system. It's done by live backends at two times: 1. A session that has used a temp schema will normally clean out the contained objects when it exits. 2. As a backstop in case #1 fails, a session that is about to begin using a temp schema will clean out any surviving contents. So if you rewound to a point where some temp objects exist, it'd be the responsibility of the first session that wants to use a given temp schema to clean out those objects. regards, tom lane