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 1pHhIS-0006Dt-8N for pgsql-general@arkaria.postgresql.org; Tue, 17 Jan 2023 08:26:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pHhIQ-0003ms-W7 for pgsql-general@arkaria.postgresql.org; Tue, 17 Jan 2023 08:26:18 +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 1pHhIQ-0003mF-LW for pgsql-general@lists.postgresql.org; Tue, 17 Jan 2023 08:26:18 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pHhIO-0000gy-0b for pgsql-general@postgresql.org; Tue, 17 Jan 2023 08:26:17 +0000 Received: by mail-ej1-x62f.google.com with SMTP id vw16so10395881ejc.12 for ; Tue, 17 Jan 2023 00:26:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=36J7uZ91G6ZYrOhmSBvBkkeZdOCPSoTKX71+3IuiD1o=; b=ljxWgTYB+abqjq6QCjwV9CS14NohnrCuMW1Mnc1MMAe9rLEAoDEtJ/sQsgwp0oRUrJ 5N7eVwV2JN8pdWX2csrGy+eg10hRIwicuBr/ARJrXo52PBANrwCXzakA23rTm0erAu/C aAsbTxqOQAwUNRsPXLRHbzeSFaStXYsy9ZJKMvM8Yy9rtFEw6fq3l3LtKKyfZaus8AHX ixNjtgPxq1+JhDmGAEDgzbMbqipdfwLcrjJ8QTkLE58H9zsDtB32fU8izbN4M1yqO2Cd iN4aGrOb8hS8AMpeAO18OyBFV79e5F/2M9W4c6KcdZ+vcL0NbisjfcmOZ9JggavaaM4i NVyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=36J7uZ91G6ZYrOhmSBvBkkeZdOCPSoTKX71+3IuiD1o=; b=Uv84+YzP5TwQ2q5S7qdqJYBEK7oWdcO8QObt9WWgq9mn3c15G+EXZ7OvrjdFqNpEpG pwz4Wcm8cuGfI6ZXRfPImXd5nPBvYvk/KlkaHfnxVbWGrn1aqm7vzD0hRSQMWLT8M78X RXi4s3DEGUW1hGLKZ9i8POdFhkHW5qSFSVUGPbGwDinLM4/hGdc20QcHAH/K/o1Zs3Ua 2sG6030w2oVYhYrF5TMDOOxb13lUXUdknZBPXOqCCkQAHUl1FPciCahAoTMJK+gycoxM wuL2q+K1CP4FbGdgoEk8+f4MgU/F3lTIGFO9pPNBxvEoRte8fLx6Jck30EScaWpsw0Dn vB5w== X-Gm-Message-State: AFqh2kq2IL6HAVGiPBhEnkqQ8vdgVgWqUdHmDsNTXzoORqnmrQUyjAw7 hS6CwcZXfPQ3jV/UOeEfWwyFSA== X-Google-Smtp-Source: AMrXdXuYeKr1EzDVSdDTwyFOCUxYeV+SrarxQspzXT+7JVSYr6DiYMFFp7aywxaVjbxF+q3+Dir02A== X-Received: by 2002:a17:907:9620:b0:871:2051:6377 with SMTP id gb32-20020a170907962000b0087120516377mr2685661ejc.60.1673943974506; Tue, 17 Jan 2023 00:26:14 -0800 (PST) Received: from dynamic-pd01.res.v6.highway.a1.net ([2001:871:5e:539:1b2c:c52a:475d:310c]) by smtp.gmail.com with ESMTPSA id ti3-20020a170907c20300b0087190b46ab0sm1529925ejc.76.2023.01.17.00.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 00:26:14 -0800 (PST) Message-ID: Subject: Re: Are ZFS snapshots unsafe when PGSQL is spreading through multiple zpools? From: Laurenz Albe To: HECTOR INGERTO , Magnus Hagander Cc: "pgsql-general@postgresql.org " Date: Tue, 17 Jan 2023 09:26:13 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-01-16 at 14:37 +0000, HECTOR INGERTO wrote: > > The database relies on the data being consistent when it performs crash= recovery. > > Imagine that a checkpoint is running while you take your snapshot.=C2= =A0 The checkpoint > > syncs a data file with a new row to disk.=C2=A0 Then it writes a WAL re= cord and updates > > the control file.=C2=A0 Now imagine that the table with the new row is = on a different > > file system, and your snapshot captures the WAL and the control file, b= ut not > > the new row (it was still sitting in the kernel page cache when the sna= pshot was taken). > > You end up with a lost row. > >=20 > > That is only one scenario.=C2=A0 Many other ways of corruption can happ= en. > =C2=A0 > Can we say then that the risk comes only from the possibility of a checkp= oint running > inside the time gap between the non-simultaneous snapshots? Another case: a transaction COMMITs, and a slightly later transaction reads= the data and sets a hint bit. If the snapshot of the file system with the data dire= ctory in it is slightly later than the snapshot of the file system with "pg_wal", the C= OMMIT might not be part of the snapshot, but the hint bit could be. Then these uncommitted data could be visible if you recover from the snapsh= ot. Yours, Laurenz Albe --=20 Cybertec | https://www.cybertec-postgresql.com