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 1np9BG-00088m-M3 for pgsql-general@arkaria.postgresql.org; Thu, 12 May 2022 13:48:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1np9BF-0002Ou-Jp for pgsql-general@arkaria.postgresql.org; Thu, 12 May 2022 13:48:37 +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 1np9BF-0002NO-A4 for pgsql-general@lists.postgresql.org; Thu, 12 May 2022 13:48:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1np9B8-0005R4-Op for pgsql-general@lists.postgresql.org; Thu, 12 May 2022 13:48:36 +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 24CDmRFG308685; Thu, 12 May 2022 09:48:28 -0400 From: Tom Lane To: "Zwettler Markus (OIZ)" cc: Ron , "pgsql-general@lists.postgresql.org" Subject: Re: AW: [Extern] Re: consistent postgresql snapshot In-reply-to: <0c12435782ab4e3e8cc0366a44e35c84@zuerich.ch> References: <49bb084a06194e51a2d58421e5f074f6@zuerich.ch> <1ba59e2c-b0ae-387f-1272-cdbeefe7bd67@gmail.com> <0c12435782ab4e3e8cc0366a44e35c84@zuerich.ch> Comments: In-reply-to "Zwettler Markus (OIZ)" message dated "Thu, 12 May 2022 09:10:15 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <308683.1652363307.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 12 May 2022 09:48:27 -0400 Message-ID: <308684.1652363307@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Zwettler Markus (OIZ)" writes: > I don't want to do use the normal backup algorithm where pg_start_backup= + pg_stop_backup will fix any fractured block and I am required to have a= ll archived logfiles, therefore. > I want to produce an atomic consistent disk snapshot. [ shrug... ] You can't have that. There is never any guarantee that the on-disk database files are fully up-to-date while the Postgres server is running, because there may be updates sitting in buffers in shared memory that have not been written out yet. We achieve crash safety by ensuring that the WAL log contains sufficient info to recreate any such updates by replaying WAL from the last checkpoint. But without going through that replay process, the data visible in the filesystem may be inconsistent. Even taking a disk snapshot immediately after a checkpoint won't help, because we use spread checkpoints. These points are independent of the possibility that any one block write is non-atomic, although that's surely a factor as well. The only way you could get a consistent on-disk image is to shut the server down (being sure to do a clean not "immediate" shutdown) and then take the snapshot. regards, tom lane