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 1jbcOE-0007O8-4Z for pgsql-bugs@arkaria.postgresql.org; Thu, 21 May 2020 04:01:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jbcNg-0000zq-Jz for pgsql-bugs@arkaria.postgresql.org; Thu, 21 May 2020 04:00:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jbcNg-0000zj-DX for pgsql-bugs@lists.postgresql.org; Thu, 21 May 2020 04:00:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jbcNZ-0002hx-Jq for pgsql-bugs@lists.postgresql.org; Thu, 21 May 2020 04:00:27 +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 04L40KEp026903; Thu, 21 May 2020 00:00:20 -0400 From: Tom Lane To: "Albin, Lloyd P" cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #16454: Mixed isolation levels inside transactions In-reply-to: References: <16454-9408996bb1750faf@postgresql.org> <22443.1590027242@sss.pgh.pa.us> Comments: In-reply-to "Albin, Lloyd P" message dated "Thu, 21 May 2020 02:51:34 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26901.1590033620.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 21 May 2020 00:00:20 -0400 Message-ID: <26902.1590033620@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Albin, Lloyd P" writes: >> As a general rule, all internal catalog accesses use latest-committed d= ata (so effectively Read Committed) = >> regardless of what the user-level visibility semantics are. This has t= o be so, because it just wouldn't do to = >> not be working with the latest data. As an example, you don't get to i= gnore a CHECK constraint just >> because it got added after your transaction started. > I agree with your CHECK constraint use case, IF you were adding data the= n you are using the READ WRITE property, BUT this transaction was set to u= se the READ ONLY property. The READ ONLY property would be better served t= o by matching data and system tables instead of using the mixed/hybrid iso= lation level. [ shrug... ] You are trying to wish away a very complicated set of problems. The CHECK case was merely an easy-to-grasp example; it's by no means the only issue. As a different example, suppose that someone DROPs an enormous table. Should we block the drop from really happening (and hence not reclaim the disk space) because somewhere there is a serializable transaction that could perhaps try to read that table later? You might say "I'm okay with having the serializable transaction fail with a serialization error if it does try to access such a table later". But then we'd be looking at trying to classify each internal catalog access as to how it should be handled in a serializable transaction, maybe with different rules for read-only vs read-write transactions. That would be a herculean task fraught with possibilities for error, and it might well require major code refactoring to ensure that there was a unique answer for each case. I don't think anybody's interested in tackling that job for such small returns in terms of practical usefulness of the system. (Admittedly, whether the returns are small is a judgment call ... but you've not even tried to make a case for why this anomaly is a problem for you, or why you couldn't dodge it by doing things differently.) I do concede that this isn't adequately documented. https://www.postgresql.org/docs/current/mvcc-caveats.html talks about some holes in the MVCC semantics model, but it doesn't mention this set of issues. regards, tom lane