Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s93vr-00H5DS-UL for pgsql-general@arkaria.postgresql.org; Mon, 20 May 2024 14:24:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s93vr-002Vjq-Ns for pgsql-general@arkaria.postgresql.org; Mon, 20 May 2024 14:24:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s93vr-002Vji-Cl for pgsql-general@lists.postgresql.org; Mon, 20 May 2024 14:24:07 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s93vo-0018PF-TR for pgsql-general@lists.postgresql.org; Mon, 20 May 2024 14:24:06 +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 44KEO2fr3508052; Mon, 20 May 2024 10:24:02 -0400 From: Tom Lane To: PetSerAl cc: Guillaume Lelarge , pgsql-general@lists.postgresql.org Subject: Re: pg_dump and not MVCC-safe commands In-reply-to: References: Comments: In-reply-to PetSerAl message dated "Mon, 20 May 2024 13:36:08 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3508050.1716215042.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 20 May 2024 10:24:02 -0400 Message-ID: <3508051.1716215042@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PetSerAl writes: > My question: > What happens if not MVCC-safe command committed after snapshot but befor= e lock? Then you'd get a dump that's not exactly consistent with the state at the time of the snapshot. However, it would be the very same database state that any other query would see at that time. So if it's functionally inconsistent for your purposes, then you brought that on your own head by using TRUNCATE concurrently with other operations. The other thing I can think of that's a hazard in this area is that pg_dump will record current values of sequence objects that may be advanced beyond where the sequence was at the instant of the snapshot, since nextval() isn't MVCC-safe. There are a lot of other ways (rollbacks and crashes) in which a sequence can get advanced beyond the last derived value you can find in the database, so an application that finds this to be unacceptable should probably not be using sequences. regards, tom lane