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 1pXDqI-0005jo-TW for pgsql-bugs@arkaria.postgresql.org; Wed, 01 Mar 2023 04:13:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pXDqG-000888-Ab for pgsql-bugs@arkaria.postgresql.org; Wed, 01 Mar 2023 04:13:24 +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 1pXDqG-00087y-24 for pgsql-bugs@lists.postgresql.org; Wed, 01 Mar 2023 04:13:24 +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 1pXDqD-000729-0i for pgsql-bugs@lists.postgresql.org; Wed, 01 Mar 2023 04:13:23 +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 3214DHZZ1311640; Tue, 28 Feb 2023 23:13:18 -0500 From: Tom Lane To: "David G. Johnston" cc: Keyerror Smart , Julien Rouhaud , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17812: LOCK TABLE IN ACCESS EXCLUSIVE MODE with a view returns an empty tuple set In-reply-to: References: <17812-206eaec1d133a94a@postgresql.org> <20230228135252.agaj42dik5qfjjxi@jrouhaud> <20230301025229.rxmmjxfvg45w2cj4@jrouhaud> Comments: In-reply-to "David G. Johnston" message dated "Tue, 28 Feb 2023 20:40:15 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1311638.1677643997.1@sss.pgh.pa.us> Date: Tue, 28 Feb 2023 23:13:17 -0500 Message-ID: <1311639.1677643997@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > You may find the following to be informative as well. A general comment on these examples is that we don't intend MVCC guarantees to hold with respect to tables that are created/dropped by other sessions midway through your transaction. The reason can be understood from this example: Session 1: BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ; SELECT * FROM table1; -- establishes session1's snapshot Session 2: DROP TABLE table2; CREATE TABLE table2 ... Session 1: SELECT * FROM table2; Strict MVCC semantics would require that session 1 now see the old contents of table2, which implies basically that we can't ever drop tables --- at the point of the DROP, there was absolutely nothing indicating that session 1 would take any interest in table2, but after the fact it wants to know about it. That's not how it works; if DROP is able to obtain exclusive lock on table2, that table is toast, immediately. (I think that if you use SERIALIZABLE level, you might get a serialization failure from the "SELECT * FROM table2", or if you don't then perhaps it'd be reasonable to fix it so you do. But under no circumstances are we going to sit on the data in table2 on the off chance that some transaction might want it later.) Like Julien, I'm not entirely sure how well this is documented. There is plenty of detail in [1] though. regards, tom lane [1] https://www.postgresql.org/docs/current/mvcc.html