Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V4ToM-0008CO-7j for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2013 10:39:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V4ToL-0006oF-Ie for pgsql-general@arkaria.postgresql.org; Wed, 31 Jul 2013 10:39:17 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V4ToI-0006o4-Q8 for pgsql-general@postgresql.org; Wed, 31 Jul 2013 10:39:15 +0000 Received: from mail-we0-x22c.google.com ([2a00:1450:400c:c03::22c]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V4ToF-0006XC-3p for pgsql-general@postgresql.org; Wed, 31 Jul 2013 10:39:13 +0000 Received: by mail-we0-f172.google.com with SMTP id t61so442833wes.17 for ; Wed, 31 Jul 2013 03:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=OPDZhEKOenxBZtipPodLwF+c81qk2CYBWY/Xwxru/m0=; b=gNWjBmTMWp36ty0X1Qe0m143QgczhGTdvv2BWTpibP+ak2q5BxM9zSHc5yEpJNbvcd AAlAieG3xqAXn7LWNlHvNebuouWcfGAPfBgFGLPowoT5iiQxBnBtUhjoryCvwysXNkoG bD1FOzVMqkJwY+OmuqpLIRukxgIv4mrmdcnH2Mhpm/PvCPNZE2jUUEijVHrR644ed31L TNp79SgcAS3oSC9fdgVwF4d/B/4qAv38H+WaRnzOxe1WHSyNoP6UDsJ9XzpejAn4ZVju poi8vShYzS2kkJtO2PwARS7zBzpkjHTIg97T7/AUFMIV0O2hDYnnfZvFTZih9eVnuNz7 /ABw== X-Received: by 10.194.22.41 with SMTP id a9mr49101506wjf.16.1375267149781; Wed, 31 Jul 2013 03:39:09 -0700 (PDT) Received: from hollewijn.internal (8d690a59.ftth.concepts.nl. [141.105.10.89]) by mx.google.com with ESMTPSA id e7sm1414112wiy.4.2013.07.31.03.39.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 31 Jul 2013 03:39:08 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: Snapshot backups From: Alban Hertroys In-Reply-To: <8810.1375247630@sss.pgh.pa.us> Date: Wed, 31 Jul 2013 12:39:07 +0200 Cc: Jeff Janes , James Sewell , "pgsql-general@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <2EB17B60-33A2-4855-A176-0E8DD16ED7E1@gmail.com> References: <8810.1375247630@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.1508) X-Pg-Spam-Score: -0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On Jul 31, 2013, at 7:13, Tom Lane wrote: > Jeff Janes writes: >> On Tuesday, July 30, 2013, James Sewell wrote: >>> I understand what you are saying, and I understand how the backup_label >>> works - but I still don't understand why the pg_start and pg_stop comma= nds >>> are REQUIRED when doing a snapshot backup to ensure data integrity. >>>=20 >>> Surely not using them and restoring a snapshot is the same as starting >>> after a crash, and will result in log replay to get to the latest possi= ble >>> consistent state? >=20 >> That's true provided that all of your data is on a single volume, and you >> trust your "snapshot" to be free of bugs. >=20 > James stated to begin with that his data was spread across multiple > volumes, so it's definitely not safe for him to omit > pg_start_backup/pg_stop_backup. (=85) > For recovery from a tar backup to work, the archived copy of pg_control > must point to a spot in the WAL sequence that is before any changes that > could possibly not yet appear in any archived data files. The purpose of > pg_start_backup/pg_stop_backup is to provide the synchronization needed to > meet this requirement. >=20 > The comparable case isn't possible for crash recovery, assuming that the > OS and storage hardware implement fsync() correctly, because we'll have > fsync'd the changes to foo down to disk before updating pg_control. >=20 > Now, if you instead take a filesystem snapshot (representing some > instantaneous state of the disk contents) and run "tar" to copy that, > you have a good backup, because you must have a copy of pg_control that > will tell you to re-apply any changes that are missing from the data > files, as well as WAL files that contain the needed records. However, > this is only certain if all that data is on *one* filesystem, because > otherwise you can't be sure you have mutually consistent snapshots. > And you're vulnerable to any bugs in the filesystem's snapshot > implementation that might give you inconsistent copies of different > files. (Such bugs would probably be closely related to bugs in fsync > ... but that doesn't mean they're necessarily exactly the same.) That begs the question what happens in case of a crash or (worse) a partial= crash when multiple file systems are involved. Say, one tablespace is on a ZFS volume and one is on an UFS volume and the = ZFS code crashes. That should result in a kernel panic, of course, in which= case every file-system is stopped at the same moment and there should be a= consistent "snapshot". But what if it doesn't trigger a panic? And how would file-system recovery play into this? Would a journaled file-s= ystem roll back every segment involved in the same interrupted transaction,= or could this create an inconsistent snapshot where the original situation= (sans file-system recovery) would actually have been a preferable state to= start from? And what happens if one of these volumes would, for example, get ejected fr= om a RAID controller (because all disks in it have triggered alarms, whethe= r genuine or not) and the other volume would not get ejected? Does the database abort work or does that result in an inconsistent state? I suppose this case usually doesn't matter much, part of the database is go= ne completely anyway, but what if the RAID controller was wrong and the dis= ks are actually just fine and come back once re-inserted? That has actually= happened several times here, caused by SATA wires vibrating loose over tim= e (took me a while to discover the cause); my databases have always been on= a single volume though, so I've never had the opportunity to run into this. I realise these are typical "what if" scenario's, so I suppose answering th= ese doesn't have a high priority. It's just that I've been wondering/worryi= ng about the seeming increase of people reporting database corruption - I w= as just wondering whether issues like these might play a part in that (I'm = sure large part of it is just more people using PG these days). Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll find there is no forest. --=20 Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general