From matt@ymogen.net Fri Mar 14 15:48:17 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id 8BFA347590C for ; Fri, 14 Mar 2003 10:48:17 -0500 (EST) Received: (qmail 24093 invoked from network); 14 Mar 2003 15:48:20 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 14 Mar 2003 15:48:20 -0000 From: "Matt Clark" To: Subject: LVM snapshots Date: Fri, 14 Mar 2003 15:48:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_04B2_01C2EA41.170AC1F0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Archive-Number: 200303/223 X-Sequence-Number: 7863 This is a multi-part message in MIME format. ------=_NextPart_000_04B2_01C2EA41.170AC1F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Has anyone tried taking an LVM snapshot of a running DB? And then reverting to the snapshot? I presume one would need to take a low level backup (i.e. using dd, not tar or cp) of the snapshot to preserve the precise FS layout, but are there any other issues? I'm thinking of trying this slightly loony experiment on Postgres v 7.2.3 running on RedHat 7.3, with ext3 as the filesystem. The only 'gotchas' I can think of at the moment are: 1. the need to preserve the FS layout precisely 2. the minor pauses that occur while LVM freezes the FS to bring the snapshot online and offline. 3. the need to have the data directory and the pg_xlog directory on the same logical volume so they get snapshotted together 4. the fact that the on-disk data is much larger than the output of pg_dump, so backing up the snapshot will require quite a bit of IO Any others I've missed? If it works then it'd be a fairly neat way to keep a recent consistent copy of the DB around without having to run pg_dump every 10 minutes, which chews CPU like nobody's business. Thanks in advance for any comments. Matt Matt Clark Ymogen Ltd matt@ymogen.net corp.ymogen.net ------=_NextPart_000_04B2_01C2EA41.170AC1F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Has anyo= ne tried=20 taking an LVM snapshot of a running DB?  And then reverting to the=20 snapshot?  I presume one would need to take a low level backup (i.e. u= sing=20 dd, not tar or cp) of the snapshot to preserve the precise FS layout, = but=20 are there any other issues?
 
I'm thin= king of=20 trying this slightly loony experiment on Postgres v 7.2.3 running on RedHat= 7.3,=20 with ext3 as the filesystem.  The only 'gotchas' I can think of at the= =20 moment are:
 
1.    the need to preserve the FS layout=20 precisely
2.    the minor pauses that occur while LVM freezes= the FS=20 to bring the snapshot online and offline.
3.    the need to have the data directory and the p= g_xlog=20 directory on the same logical volume so they get snapshotted=20 together
4.    the fact that the on-disk data is much larger= than=20 the output of pg_dump, so backing up the snapshot will require quite a bit = of=20 IO
 
Any othe= rs I've=20 missed?  If it works then it'd be a fairly neat way to keep a recent= =20 consistent copy of the DB around without having to run pg_dump every 1= 0=20 minutes, which chews CPU like nobody's business.
<= /SPAN> = ;
Thanks i= n advance=20 for any comments.
 
Matt
 

Matt Clark
Ymogen Ltd
matt@ymogen.net
corp.ymogen.net

 
------=_NextPart_000_04B2_01C2EA41.170AC1F0-- From dfs@roaringpenguin.com Fri Mar 14 15:51:43 2003 X-Original-To: pgsql-admin@postgresql.org Received: from ottawa-hs-209-217-122-117.s-ip.magma.ca (ottawa-hs-209-217-122-117.s-ip.magma.ca [209.217.122.117]) by postgresql.org (Postfix) with ESMTP id 5E2EC474E44 for ; Fri, 14 Mar 2003 10:51:43 -0500 (EST) Received: from shishi.roaringpenguin.com (shishi.roaringpenguin.com [192.168.2.3]) by shevy.roaringpenguin.com (8.12.8/8.12.8) with ESMTP id h2EFplBD024258 for ; Fri, 14 Mar 2003 10:51:47 -0500 Date: Fri, 14 Mar 2003 10:51:47 -0500 (EST) From: "David F. Skoll" To: pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200303/224 X-Sequence-Number: 7864 On Fri, 14 Mar 2003, Matt Clark wrote: > Has anyone tried taking an LVM snapshot of a running DB? I don't think there's a guarantee that a snapshot of the file system corresponds to a consistent database, even if the snapshot corresponds to a single point-in-time. -- David. From Ben.Trewern@mowlem.com Fri Mar 14 16:01:25 2003 X-Original-To: pgsql-admin@postgresql.org Received: from xxx-bfhxx-ms001.mowlem.com (mail.mowlem.com [212.137.27.84]) by postgresql.org (Postfix) with ESMTP id EBEC7475C15 for ; Fri, 14 Mar 2003 11:01:25 -0500 (EST) Received: from xxx-bfhxx-ex002.mowlem.com (unverified) by xxx-bfhxx-ms001.mowlem.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Fri, 14 Mar 2003 16:02:43 +0000 Received: by XXX_BFHXX_EX002 with Internet Mail Service (5.5.2653.19) id ; Fri, 14 Mar 2003 16:03:27 -0000 Message-ID: <996802F75C3CD411B424001083FA445B534D51@CET_PONXX_FP001> From: "Trewern, Ben" To: "'David F. Skoll'" , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 16:03:16 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative ; boundary="----_=_NextPart_001_01C2EA43.391CEAA0" X-Archive-Number: 200303/225 X-Sequence-Number: 7865 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2EA43.391CEAA0 Content-Type: text/plain I don't see why not. What happens if your server crashes? Hopefully what's on the disk is consistent (one of the good reasons to use Postgresql). BTW I've heard of someone else doing something like this and using rsync. He was running it just before the snapshot and then again against the snapshot. This should then reduce the amount of time the actual snapshot needs to be kept. Regards, Ben -----Original Message----- From: David F. Skoll [mailto:dfs@roaringpenguin.com] Sent: 14 March 2003 15:52 To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots On Fri, 14 Mar 2003, Matt Clark wrote: > Has anyone tried taking an LVM snapshot of a running DB? I don't think there's a guarantee that a snapshot of the file system corresponds to a consistent database, even if the snapshot corresponds to a single point-in-time. -- David. ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org ***************************************************************************** This email and any attachments transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and do not store, copy or disclose the content to any other person. It is the responsibility of the recipient to ensure that opening this message and/or any of its attachments will not adversely affect its systems. No responsibility is accepted by the Company. ***************************************************************************** ------_=_NextPart_001_01C2EA43.391CEAA0 Content-Type: text/html Content-Transfer-Encoding: quoted-printable RE: [ADMIN] LVM snapshots

I don't see why not.  What happens if your server cr= ashes?  Hopefully what's on the disk is consistent (one of the good re= asons to use Postgresql).

BTW I've heard of someone else doing something like this = and using rsync.  He was running it just before the snapshot and then = again against the snapshot.  This should then reduce the amount of tim= e the actual snapshot needs to be kept.

Regards,

Ben

-----Original Message-----
From: David F. Skoll [mailto:dfs@roaringpenguin.com]
Sent: 14 March 2003 15:52
To: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] LVM snapshots

On Fri, 14 Mar 2003, Matt Clark wrote:

> Has anyone tried taking an LVM snapshot of a running= DB?

I don't think there's a guarantee that a snapshot of the = file system
corresponds to a consistent database, even if the snapsh= ot corresponds
to a single point-in-time.

--
David.

---------------------------(end of broadcast)------------= ---------------
TIP 1: subscribe and unsubscribe commands go to majordom= o@postgresql.org



***************************************************************************= **
This email and any attachments transmitted with it are confidential
and intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the sender and do not store, copy or disclose the content
to any other person.

It is the responsibility of the recipient to ensure that opening this
message and/or any of its attachments will not adversely affect
its systems. No responsibility is accepted by the Company.
***************************************************************************= **
------_=_NextPart_001_01C2EA43.391CEAA0-- From matt@ymogen.net Fri Mar 14 16:54:30 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id 514CE474E44 for ; Fri, 14 Mar 2003 11:54:30 -0500 (EST) Received: (qmail 30426 invoked from network); 14 Mar 2003 16:05:58 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 14 Mar 2003 16:05:58 -0000 From: "Matt Clark" To: Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 16:05:38 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: X-Archive-Number: 200303/227 X-Sequence-Number: 7867 I *think* it is guaranteed with WAL, otherwise the system could fail to recover after a system crash. At least that's how I read section 11.1.1 of the docs: http://www.postgresql.org/docs/view.php?version=7.2&idoc=1&file=wal.html Could freezing of the filesystem result in the WAL being fsynced at an 'inappropriate' time? Is there ever an inappropriate time to fsync the WAL? > -----Original Message----- > From: pgsql-admin-owner@postgresql.org > [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of David F. Skoll > Sent: 14 March 2003 15:52 > To: pgsql-admin@postgresql.org > Subject: Re: [ADMIN] LVM snapshots > > > On Fri, 14 Mar 2003, Matt Clark wrote: > > > Has anyone tried taking an LVM snapshot of a running DB? > > I don't think there's a guarantee that a snapshot of the file system > corresponds to a consistent database, even if the snapshot corresponds > to a single point-in-time. > > -- > David. > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > From matt@ymogen.net Fri Mar 14 16:48:42 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id C8D1B474E44 for ; Fri, 14 Mar 2003 11:48:42 -0500 (EST) Received: (qmail 7406 invoked from network); 14 Mar 2003 16:28:46 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 14 Mar 2003 16:28:46 -0000 From: "Matt Clark" To: Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 16:28:26 -0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_04BA_01C2EA46.BD3A4C80" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <996802F75C3CD411B424001083FA445B534D51@CET_PONXX_FP001> X-Archive-Number: 200303/226 X-Sequence-Number: 7866 This is a multi-part message in MIME format. ------=_NextPart_000_04BA_01C2EA46.BD3A4C80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit RE: [ADMIN] LVM snapshotsThat's what I thought. The docs are a bit coy on this point. Section 9.2 says "The database server must be shut down in order to get a usable backup. Half-way measures such as disallowing all connections will not work as there is always some buffering going on. For this reason it is also not advisable to trust file systems that claim to support "consistent snapshots". But LVM calls fsync_dev_lockfs() before the snapshot is taken, and unlockfs() afterwards, so there are guaranteed to be no dirty buffers lying around - the tradeoff is that calls to write() will block until all the buffers are written to disk and the snapshot set up, but that shouldn't take long. BTW I see I was wrong in my original question about tar &c being unsuitable, I don't know where I got that idea from, so taking a snapshot every 10 mins and doing an rsync should be pretty cheap in terms of write IO, though it will increase the CPU demands above those for a simple copy, and doesn't save anything on read IO. Is there some other interpretation of Section 9.2 of the docs that means the reasoning on fsync_dev_lockfs above is wrong or inadequate? -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Trewern, Ben Sent: 14 March 2003 16:03 To: 'David F. Skoll'; pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots I don't see why not. What happens if your server crashes? Hopefully what's on the disk is consistent (one of the good reasons to use Postgresql). BTW I've heard of someone else doing something like this and using rsync. He was running it just before the snapshot and then again against the snapshot. This should then reduce the amount of time the actual snapshot needs to be kept. Regards, Ben -----Original Message----- From: David F. Skoll [mailto:dfs@roaringpenguin.com] Sent: 14 March 2003 15:52 To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots On Fri, 14 Mar 2003, Matt Clark wrote: > Has anyone tried taking an LVM snapshot of a running DB? I don't think there's a guarantee that a snapshot of the file system corresponds to a consistent database, even if the snapshot corresponds to a single point-in-time. -- David. ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org **************************************************************************** * This email and any attachments transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and do not store, copy or disclose the content to any other person. It is the responsibility of the recipient to ensure that opening this message and/or any of its attachments will not adversely affect its systems. No responsibility is accepted by the Company. **************************************************************************** * ------=_NextPart_000_04BA_01C2EA46.BD3A4C80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [ADMIN] LVM snapshots
That's what I thought.  The docs are a bit coy on this point.=  =20 Section 9.2 says "The database server must be shut down in order to get a usable back= up.=20 Half-way measures such as disallowing all connections will not work as ther= e is=20 always some buffering going on. For this reason it is also not advisable to= =20 trust file systems that claim to support "consistent=20 snapshots".
 
But=20 LVM calls fsync_dev_lockfs() before the snapshot is taken, and unlockfs()= =20 afterwards, so there are guaranteed to be no dirty buffers lying around - t= he=20 tradeoff is that calls to write() will block until all the buffers are writ= ten=20 to disk and the snapshot set up, but that shouldn't take=20 long.
 
BTW I=20 see I was wrong in my original question about tar &c being unsuitable, = I=20 don't know where I got that idea from, so taking a snapshot every 10 mins a= nd=20 doing an rsync should be pretty cheap in terms of write IO, though it will= =20 increase the CPU demands above those for a simple copy, and doesn't save=20 anything on read IO.
 
Is=20 there some other interpretation of Section 9.2 of the docs that means the= =20 reasoning on fsync_dev_lockfs above is wrong or inadequate?
 
 
-----Original Message-----
From:=20 pgsql-admin-owner@postgresql.org=20 [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Trewern,=20 Ben
Sent: 14 March 2003 16:03
To: 'David F. Skoll';= =20 pgsql-admin@postgresql.org
Subject: Re: [ADMIN] LVM=20 snapshots

I don't see why not.  What happens if your server= =20 crashes?  Hopefully what's on the disk is consistent (one of the goo= d=20 reasons to use Postgresql).

BTW I've heard of someone else doing something like thi= s and=20 using rsync.  He was running it just before the snapshot and then ag= ain=20 against the snapshot.  This should then reduce the amount of time th= e=20 actual snapshot needs to be kept.

Regards,

Ben

-----Original Message-----
Fr= om: David=20 F. Skoll [mailto:dfs@roaringpenguin.com]= =20
Sent: 14 March 2003 15:52
To:=20 pgsql-admin@postgresql.org
Subject: Re: [ADMIN]= LVM=20 snapshots

On Fri, 14 Mar 2003, Matt Clark wrote:

> Has anyone tried taking an LVM snapshot of a runni= ng=20 DB?

I don't think there's a guarantee that a snapshot of th= e file=20 system
corresponds to a consistent database, ev= en if=20 the snapshot corresponds
to a single=20 point-in-time.

--
David.

---------------------------(end of=20 broadcast)---------------------------
TIP 1: su= bscribe=20 and unsubscribe commands go to majordomo@postgresql.org

=

********************************************************= *********************
This=20 email and any attachments transmitted with it are confidential
and int= ended=20 solely for the use of the individual or entity to whom
they are addres= sed.=20 If you have received this email in error please
notify the sender and = do=20 not store, copy or disclose the content
to any other person.

It= is=20 the responsibility of the recipient to ensure that opening this
messag= e=20 and/or any of its attachments will not adversely affect
its systems. N= o=20 responsibility is accepted by the=20 Company.
*************************************************************= ****************
------=_NextPart_000_04BA_01C2EA46.BD3A4C80-- From tgl@sss.pgh.pa.us Fri Mar 14 17:17:12 2003 X-Original-To: pgsql-admin@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id C0CF5475AD4 for ; Fri, 14 Mar 2003 12:17:12 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2EHHFub022013; Fri, 14 Mar 2003 12:17:17 -0500 (EST) To: "Matt Clark" Cc: pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: References: Comments: In-reply-to "Matt Clark" message dated "Fri, 14 Mar 2003 15:48:00 +0000" Date: Fri, 14 Mar 2003 12:17:15 -0500 Message-ID: <22012.1047662235@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/228 X-Sequence-Number: 7868 "Matt Clark" writes: > Has anyone tried taking an LVM snapshot of a running DB? And then reverting > to the snapshot? I presume one would need to take a low level backup (i.e. > using dd, not tar or cp) of the snapshot to preserve the precise FS layout, > but are there any other issues? This was discussed only a couple weeks ago (in the context of a similar facility in NetApp servers, but I believe LVM was mentioned). See the archives. regards, tom lane From matt@ymogen.net Fri Mar 14 17:46:41 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id 03C7B475AD4 for ; Fri, 14 Mar 2003 12:46:41 -0500 (EST) Received: (qmail 5995 invoked from network); 14 Mar 2003 17:46:45 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 14 Mar 2003 17:46:45 -0000 From: "Matt Clark" To: "Tom Lane" Cc: Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 17:46:24 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <22012.1047662235@sss.pgh.pa.us> X-Archive-Number: 200303/229 X-Sequence-Number: 7869 A search for 'netapp' or 'lvm' doesn't seem to throw anything relevant up on any of the lists, and I can't *see* any likely threads in this group for Jan, Feb or March. I'm probably just being blind - can anyone recall the Subject: of the thread? Cheers Matt > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: 14 March 2003 17:17 > To: Matt Clark > Cc: pgsql-admin@postgresql.org > Subject: Re: [ADMIN] LVM snapshots > > > "Matt Clark" writes: > > Has anyone tried taking an LVM snapshot of a running DB? And then reverting > > to the snapshot? I presume one would need to take a low level backup (i.e. > > using dd, not tar or cp) of the snapshot to preserve the precise FS layout, > > but are there any other issues? > > This was discussed only a couple weeks ago (in the context of a similar > facility in NetApp servers, but I believe LVM was mentioned). See the > archives. > > regards, tom lane > From Ben.Trewern@mowlem.com Fri Mar 14 17:52:53 2003 X-Original-To: pgsql-admin@postgresql.org Received: from xxx-bfhxx-ms001.mowlem.com (mail.mowlem.com [212.137.27.84]) by postgresql.org (Postfix) with ESMTP id 282A7475E9D for ; Fri, 14 Mar 2003 12:52:53 -0500 (EST) Received: from xxx-bfhxx-ex002.mowlem.com (unverified) by xxx-bfhxx-ms001.mowlem.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Fri, 14 Mar 2003 17:54:09 +0000 Received: by XXX_BFHXX_EX002 with Internet Mail Service (5.5.2653.19) id ; Fri, 14 Mar 2003 17:54:53 -0000 Message-ID: <996802F75C3CD411B424001083FA445B534D53@CET_PONXX_FP001> From: "Trewern, Ben" To: 'Matt Clark' Cc: pgsql-admin@postgresql.org Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 17:54:45 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative ; boundary="----_=_NextPart_001_01C2EA52.CC304AD0" X-Archive-Number: 200303/230 X-Sequence-Number: 7870 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2EA52.CC304AD0 Content-Type: text/plain Try - [GENERAL] A few questions to real pgsql gurus Ben -----Original Message----- From: Matt Clark [mailto:matt@ymogen.net] Sent: 14 March 2003 17:46 To: Tom Lane Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots A search for 'netapp' or 'lvm' doesn't seem to throw anything relevant up on any of the lists, and I can't *see* any likely threads in this group for Jan, Feb or March. I'm probably just being blind - can anyone recall the Subject: of the thread? Cheers Matt > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: 14 March 2003 17:17 > To: Matt Clark > Cc: pgsql-admin@postgresql.org > Subject: Re: [ADMIN] LVM snapshots > > > "Matt Clark" writes: > > Has anyone tried taking an LVM snapshot of a running DB? And then reverting > > to the snapshot? I presume one would need to take a low level backup (i.e. > > using dd, not tar or cp) of the snapshot to preserve the precise FS layout, > > but are there any other issues? > > This was discussed only a couple weeks ago (in the context of a similar > facility in NetApp servers, but I believe LVM was mentioned). See the > archives. > > regards, tom lane > ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html ***************************************************************************** This email and any attachments transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and do not store, copy or disclose the content to any other person. It is the responsibility of the recipient to ensure that opening this message and/or any of its attachments will not adversely affect its systems. No responsibility is accepted by the Company. ***************************************************************************** ------_=_NextPart_001_01C2EA52.CC304AD0 Content-Type: text/html Content-Transfer-Encoding: quoted-printable RE: [ADMIN] LVM snapshots

Try - [GENERAL] A few questions to real pgsql gurus

Ben

-----Original Message-----
From: Matt Clark [mai= lto:matt@ymogen.net]
Sent: 14 March 2003 17:46
To: Tom Lane
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] LVM snapshots

A search for 'netapp' or 'lvm' doesn't seem to throw anyt= hing relevant up on any of the lists, and I can't *see* any likely threads<= /FONT>

in this group for Jan, Feb or March.  I'm probably j= ust being blind - can anyone recall the Subject: of the thread?

Cheers

Matt


> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: 14 March 2003 17:17
> To: Matt Clark
> Cc: pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] LVM snapshots
>
>
> "Matt Clark" <matt@ymogen.net> writ= es:
> > Has anyone tried taking an LVM snapshot of a r= unning DB?  And then reverting
> > to the snapshot?  I presume one would nee= d to take a low level backup (i.e.
> > using dd, not tar or cp) of the snapshot to pr= eserve the precise FS layout,
> > but are there any other issues?
>
> This was discussed only a couple weeks ago (in the = context of a similar
> facility in NetApp servers, but I believe LVM was m= entioned).  See the
> archives.
>
>          &n= bsp;            regards, = tom lane
>



---------------------------(end of broadcast)------------= ---------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



***************************************************************************= **
This email and any attachments transmitted with it are confidential
and intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the sender and do not store, copy or disclose the content
to any other person.

It is the responsibility of the recipient to ensure that opening this
message and/or any of its attachments will not adversely affect
its systems. No responsibility is accepted by the Company.
***************************************************************************= **
------_=_NextPart_001_01C2EA52.CC304AD0-- From ler@lerctr.org Fri Mar 14 17:55:49 2003 X-Original-To: pgsql-admin@postgresql.org Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11]) by postgresql.org (Postfix) with ESMTP id 1EE51476353 for ; Fri, 14 Mar 2003 12:55:49 -0500 (EST) Received: from pppth08-150.ght.iadfw.net (pppth08-150.ght.iadfw.net [207.136.52.24]) (authenticated bits=0) by lerami.lerctr.org (8.12.8/8.12.8/20030225) with ESMTP id h2EHtnfS003840; Fri, 14 Mar 2003 11:55:51 -0600 (CST) Date: Fri, 14 Mar 2003 11:55:46 -0600 From: Larry Rosenman To: Matt Clark , Tom Lane Cc: pgsql-admin@postgresql.org Subject: Re: LVM snapshots Message-ID: <25000000.1047664545@lerlaptop.lerctr.org> In-Reply-To: References: X-Mailer: Mulberry/3.0.2 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Archive-Number: 200303/232 X-Sequence-Number: 7872 Here is the subject from my post on 2/24/03: Re: [GENERAL] A few questions to real pgsql gurus --On Friday, March 14, 2003 17:46:24 +0000 Matt Clark wrote: > A search for 'netapp' or 'lvm' doesn't seem to throw anything relevant up > on any of the lists, and I can't *see* any likely threads in this group > for Jan, Feb or March. I'm probably just being blind - can anyone recall > the Subject: of the thread? > > Cheers > > Matt > > >> -----Original Message----- >> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] >> Sent: 14 March 2003 17:17 >> To: Matt Clark >> Cc: pgsql-admin@postgresql.org >> Subject: Re: [ADMIN] LVM snapshots >> >> >> "Matt Clark" writes: >> > Has anyone tried taking an LVM snapshot of a running DB? And then >> > reverting to the snapshot? I presume one would need to take a low >> > level backup (i.e. using dd, not tar or cp) of the snapshot to >> > preserve the precise FS layout, but are there any other issues? >> >> This was discussed only a couple weeks ago (in the context of a similar >> facility in NetApp servers, but I believe LVM was mentioned). See the >> archives. >> >> regards, tom lane >> > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749 From matt@ymogen.net Fri Mar 14 18:22:15 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id 25D5A476350 for ; Fri, 14 Mar 2003 13:22:15 -0500 (EST) Received: (qmail 20142 invoked from network); 14 Mar 2003 18:22:15 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 14 Mar 2003 18:22:15 -0000 From: "Matt Clark" To: Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 18:21:53 -0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_04C4_01C2EA56.96ACA8A0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <996802F75C3CD411B424001083FA445B534D53@CET_PONXX_FP001> X-Archive-Number: 200303/233 X-Sequence-Number: 7873 This is a multi-part message in MIME format. ------=_NextPart_000_04C4_01C2EA56.96ACA8A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit RE: [ADMIN] LVM snapshotsThanks all. The conclusion there seemed to be that it ought to work just fine, but should be tested. Well, I'll test it and see if anything interesting comes up. If anything LVM snapshots will be less tricky than NetApp snapshots as LVM has access to the OS's local cache buffers, whereas the NetApp doesn't (though presumably the OS shouldn't/doesn't do any write caching when writing to a network FS). -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Trewern, Ben Sent: 14 March 2003 17:55 To: 'Matt Clark' Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots Try - [GENERAL] A few questions to real pgsql gurus Ben ------=_NextPart_000_04C4_01C2EA56.96ACA8A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [ADMIN] LVM snapshots
Thanks all.
 
The=20 conclusion there seemed to be that it ought to work just fine, but should b= e=20 tested.  Well, I'll test it and see if anything interesting comes up.&= nbsp;=20 If anything LVM snapshots will be less tricky than NetApp snapshots as LVM = has=20 access to the OS's local cache buffers, whereas the NetApp doesn't (though= =20 presumably the OS shouldn't/doesn't do any write caching when writing to a= =20 network FS).
 
 
 
 
-----Original Message-----
From:=20 pgsql-admin-owner@postgresql.org=20 [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Trewern,=20 Ben
Sent: 14 March 2003 17:55
To: 'Matt=20 Clark'
Cc: pgsql-admin@postgresql.org
Subject: Re: [A= DMIN]=20 LVM snapshots

Try - [GENERAL] A few questions to real pgsql gurus=20

Ben

------=_NextPart_000_04C4_01C2EA56.96ACA8A0-- From tgl@sss.pgh.pa.us Fri Mar 14 18:36:43 2003 X-Original-To: pgsql-admin@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0BDAE47634A for ; Fri, 14 Mar 2003 13:36:43 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2EIaeub022579; Fri, 14 Mar 2003 13:36:40 -0500 (EST) To: "Matt Clark" Cc: pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: References: Comments: In-reply-to "Matt Clark" message dated "Fri, 14 Mar 2003 16:05:38 +0000" Date: Fri, 14 Mar 2003 13:36:40 -0500 Message-ID: <22578.1047667000@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/234 X-Sequence-Number: 7874 "Matt Clark" writes: > Could freezing of the filesystem result in the WAL being fsynced at an > 'inappropriate' time? Is there ever an inappropriate time to fsync > the WAL? If there were it'd be a bug ... regards, tom lane From murthy.kambhampaty@goeci.com Fri Mar 14 18:58:31 2003 X-Original-To: pgsql-admin@postgresql.org Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by postgresql.org (Postfix) with ESMTP id 5379C474E44 for ; Fri, 14 Mar 2003 13:58:31 -0500 (EST) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id ; Fri, 14 Mar 2003 13:58:31 -0500 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC09218F@THOR.goeci.com> From: Murthy Kambhampaty To: 'Matt Clark' , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 13:58:30 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C2EA5B.B4057DDC" X-Archive-Number: 200303/235 X-Sequence-Number: 7875 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C2EA5B.B4057DDC Content-Type: text/plain; charset="iso-8859-1" Here's the script I use to mount a snapshot and rsync to a remote server; postgresql is started and stopped on the remote server as part of the backup procedure to make sure that the backup log contains any errors that might show up. The restore strategy is to start the postmaster on the remote server and dump restore like so: pgdump -Fc -h -U -d -t | pgrestore -h -U -d -t
[-c] Note that this is not particularly safe with 7.3, since pgrestore will try to restore every table in the database with the given name. If you use the schema feature that allows indentically named tables in different schema, you're in for trouble when you recover it. Backup restore has been tested so far by restoring a table and comparing the contents; they were identical. Thanks to rsync performance is fantastic compared to pgdump to a file (my past e-mail to the list will give some idea of the problems we've had with that). I'd be interested in comments on the strategy and the script itself. Cheers, Murthy -----Original Message----- From: Matt Clark [mailto:matt@ymogen.net] Sent: Friday, March 14, 2003 13:22 To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots Thanks all. The conclusion there seemed to be that it ought to work just fine, but should be tested. Well, I'll test it and see if anything interesting comes up. If anything LVM snapshots will be less tricky than NetApp snapshots as LVM has access to the OS's local cache buffers, whereas the NetApp doesn't (though presumably the OS shouldn't/doesn't do any write caching when writing to a network FS). -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Trewern, Ben Sent: 14 March 2003 17:55 To: 'Matt Clark' Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots Try - [GENERAL] A few questions to real pgsql gurus Ben ------_=_NextPart_000_01C2EA5B.B4057DDC Content-Type: application/octet-stream; name="pgSnapBack.sh" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pgSnapBack.sh" #!/bin/bash # FN: pgsnapshot. # AB: creates and mounts snapshot of $PGDATA; rsyncs from compa5; # reinitializes database on backup server; unmounts and removes snapshot # DT: 2003-03-05 # AU: S. Murthy Kambhampaty # An e-mail address for the monitor: pgMonitor=3D"" # "log" instances of this script as follows: # (this form is good for unattended scripts; for manually run scripts # you might want to save and restore stdin and stdout; see # http://www.tldp.org/LDP/abs/html/x11830.html#REDIR, example 16-3) LogFile=3D"/var/log/`basename $0 .sh`-`date +%Y%m%d-%H%M`" exec > "$LogFile" exec 2> "$LogFile.err" echo "$(date +%c): Backup initiated" pgSRV=3D"$(echo -e `hostname` | awk 'BEGIN{FS=3D"."}{print $1}')" BackupSRV=3D"host2" DataFS=3D"/home/db" DataLV=3D"/dev/VG00/LVdb" SnapNM=3D"pgsnapshot" SnapLV=3D"/dev/VG00/$SnapNM" SnapDir=3D"/mnt/$SnapNM" RshCMD=3D"ssh -i /home/postgres/.ssh/id_rsa postgres@$BackupSRV" RsyncSRC=3D"$pgSRV::pgsnapshot/pgsql/" RsyncDST=3D"/home/db/mirrors/$pgSRV" RsyncOpts=3D"-avW --stats --exclude=3D'postmaster.pid' --delete" # First vacuum all databases echo $'\n\n' "$(date +%c): Vacuuming databases on `hostname`" # Mark vacuum start and end in the log to ease log navigation /usr/local/pgsql/bin/psql -U pguser -d template1 -c \ "select '+++++ Nightly Vacuum About To Commence +++++'" >/dev/null /usr/local/pgsql/bin/vacuumdb -U postgres -q -a && \ /usr/local/pgsql/bin/psql -U pguser -d template1 -c \ "select '+++++ Nightly Vacuum Completed +++++'" >/dev/null && \ echo $'\n\t' "$(date +%c): Successfully vacuumed databases on `hostname`" # Now create and mount the snapshot volume echo $'\n\n' "$(date +%c): Snapshot creation and mounting" /usr/sbin/xfs_freeze -f "$DataFS" /sbin/lvcreate -s -l 1536 -n "$SnapNM" "$DataLV"; SnapTest=3D$? # Record ex= it status of lvcreate /usr/sbin/xfs_freeze -u "$DataFS" # If snapshot creation succeeded, mount the snapshot volume; else bail if [[ $SnapTest -eq 0 ]]; then echo $'\n\t' "$(date +%c): Successfully created snapshot" mount "$SnapLV" "$SnapDir" -o nouuid,norecovery,ro else echo $'\n\t' "$(date +%c): Snapshot failed." \ $'\n\t' "(Is it already mounted?)" \ $'\n\t' "!!! Terminating backup ..." >&2 exit fi # Do the backup # The backup is controlled from a remote shell on the backup server # to keep CPU utilization on the database server low echo $'\n\n' "$(date +%c): Rsync from snapshot to mirror on $BackupSRV" $RshCMD rsync "$RsyncOpts" "$RsyncSRC" "$RsyncDST" 2>&1 && \ echo "$(date +%c): Rsync complete"; echo $'\n\n' # Remove the snapshot on rsync completion umount "$SnapLV" /sbin/lvremove -f "$SnapLV" # "Reinitialize" the snapshot of the database on the backup server echo $'\n\n' "$(date +%c): Start postmaster on $BackupSRV, capture output, = and shutdown" $RshCMD /usr/local/pgsql-7.3/bin/postmaster -D "$RsyncDST/data" 2>&1 & sleep 60 # give the postmaster time for recovery $RshCMD /usr/local/pgsql-7.3/bin/pg_ctl stop -D "$RsyncDST/data" echo $'\n\n' "$(date +%c): Attempted to reinitialize backup; check for erro= rs above" if [ ! -s "$LogFile.err" ]; then rm -f "$LogFile.err" echo $'\n\n' "$(date +%c): Backup completed (without errors)-ish" # Why do= es postmaster log to sterr, rather than stdout? :-( else cat "$LogFile.err" | /usr/sbin/postfix.sendmail $pgMonitor echo $'\n\n' "$(date +%c): Backup encountered errors" \ $'\t' "Notified $pgMonitor" fi ------_=_NextPart_000_01C2EA5B.B4057DDC-- From matt@ymogen.net Sat Mar 15 23:45:06 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id 9FD94475FD9 for ; Sat, 15 Mar 2003 18:45:06 -0500 (EST) Received: (qmail 7791 invoked from network); 15 Mar 2003 23:45:07 -0000 Received: from unknown (HELO ymogen.net) (mailuser@194.164.65.179) by 0 with SMTP; 15 Mar 2003 23:45:07 -0000 Message-ID: <3E73BB01.2020403@ymogen.net> Date: Sat, 15 Mar 2003 23:45:05 +0000 From: Matt User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Murthy Kambhampaty Cc: pgsql-admin@postgresql.org Subject: Re: LVM snapshots References: <2D92FEBFD3BE1346A6C397223A8DD3FC09218F@THOR.goeci.com> In-Reply-To: <2D92FEBFD3BE1346A6C397223A8DD3FC09218F@THOR.goeci.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/240 X-Sequence-Number: 7880 Murthy Kambhampaty wrote: >Backup restore has been tested so far by restoring a table and comparing the >contents; they were identical. Thanks to rsync performance is fantastic >compared to pgdump to a file (my past e-mail to the list will give some idea >of the problems we've had with that). I'd be interested in comments on the >strategy and the script itself. > > > Many thanks for the detailed info! As I see it the discussion so far says: 1. The strategy should theoretically work (coy comments in the docs notwithstanding) 2. It works for you in practice 3. It works very efficiently when using rsync The only potential missing piece that I can see is some thorough stress-testing, such as running say 50 updates/second against a multi-table DB while the snapshotting and backup takes place, then testing the snapshotted DB. Is the DB you have been backing up under significant load when you take the snapshot? If the theory can be robustly demonstrated to work in practice (which you may have already done) then I say this strategy needs to be recognised in the docs (or at least the techdocs) as a valid and useful one. From peter_e@gmx.net Sun Mar 16 14:04:49 2003 X-Original-To: pgsql-admin@postgresql.org Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id D03DC475AD4 for ; Sun, 16 Mar 2003 09:04:49 -0500 (EST) Received: (qmail 19543 invoked by uid 0); 16 Mar 2003 14:04:52 -0000 Received: from p3E9E7084.dip0.t-ipconnect.de (62.158.112.132) by mail.gmx.net (mp023-rz3) with SMTP; 16 Mar 2003 14:04:52 -0000 Date: Sun, 16 Mar 2003 15:05:21 +0100 (CET) From: Peter Eisentraut X-X-Sender: peter@peter.localdomain To: Matt Cc: Murthy Kambhampaty , Subject: Re: LVM snapshots In-Reply-To: <3E73BB01.2020403@ymogen.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200303/243 X-Sequence-Number: 7883 Matt writes: > If the theory can be robustly demonstrated to work in practice (which > you may have already done) then I say this strategy needs to be > recognised in the docs (or at least the techdocs) as a valid and useful one. The note in the documentation is rather old. If you can conclusively disprove it, then we'll be happy to alter it. -- Peter Eisentraut peter_e@gmx.net From tgl@sss.pgh.pa.us Sun Mar 16 17:50:58 2003 X-Original-To: pgsql-admin@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E9E3A474E42 for ; Sun, 16 Mar 2003 12:50:58 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2GHowub021198; Sun, 16 Mar 2003 12:50:58 -0500 (EST) To: Peter Eisentraut Cc: Matt , Murthy Kambhampaty , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: References: Comments: In-reply-to Peter Eisentraut message dated "Sun, 16 Mar 2003 15:05:21 +0100" Date: Sun, 16 Mar 2003 12:50:58 -0500 Message-ID: <21197.1047837058@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/245 X-Sequence-Number: 7885 Peter Eisentraut writes: > Matt writes: >> If the theory can be robustly demonstrated to work in practice (which >> you may have already done) then I say this strategy needs to be >> recognised in the docs (or at least the techdocs) as a valid and useful one. > The note in the documentation is rather old. If you can conclusively > disprove it, then we'll be happy to alter it. More to the point, the note is intended to discourage people from using simple methods like tar or rsync duplication, which will most definitely not work. A snapshot implemented with help from something that sits between Postgres and the disk theoretically could work. Being conservative database weenies, we'd like to see some proof that it actually works in practical cases before we endorse it ;-). BTW: aside from the question of the integrity of the snapshot backup, I'd be inclined to ask hard questions about the effects on database performance from using the disk-freezing feature in the first place. What is the LVM layer doing with the writes that occur while the frozen snapshot is maintained?? If they're not getting to disk at all, then "commits" that occur during the freeze aren't really commits (and one can be pardoned for wondering whether write ordering constraints will be honored when the floodgate is reopened). If they are getting to disk, this seems to imply data journaling is being used, which is probably a net loss for overall database performance. You might be willing to pay that cost to be able to use this backup technique --- but you should find out what that cost is ... regards, tom lane From postgres@ragnark.vestdata.no Mon Mar 17 12:32:08 2003 X-Original-To: pgsql-admin@postgresql.org Received: from stine.vestdata.no (stine.vestdata.no [195.204.68.10]) by postgresql.org (Postfix) with ESMTP id D7BC5474E53 for ; Mon, 17 Mar 2003 07:32:08 -0500 (EST) Received: (from ragnark@localhost) by stine.vestdata.no (8.11.6/8.11.6) id h2HCVWW18933; Mon, 17 Mar 2003 13:31:32 +0100 Date: Mon, 17 Mar 2003 13:31:32 +0100 From: Ragnar =?iso-8859-15?B?S2rDuHJzdGFk?= To: Tom Lane Cc: Peter Eisentraut , Matt , Murthy Kambhampaty , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Message-ID: <20030317123132.GC24425@vestdata.no> References: <21197.1047837058@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <21197.1047837058@sss.pgh.pa.us> User-Agent: Mutt/1.5.2i X-Archive-Number: 200303/250 X-Sequence-Number: 7890 On Sun, Mar 16, 2003 at 12:50:58PM -0500, Tom Lane wrote: > BTW: aside from the question of the integrity of the snapshot backup, > I'd be inclined to ask hard questions about the effects on database > performance from using the disk-freezing feature in the first place. > What is the LVM layer doing with the writes that occur while the > frozen snapshot is maintained?? If they're not getting to disk at > all, then "commits" that occur during the freeze aren't really commits > (and one can be pardoned for wondering whether write ordering > constraints will be honored when the floodgate is reopened). If they > are getting to disk, this seems to imply data journaling is being used, > which is probably a net loss for overall database performance. You > might be willing to pay that cost to be able to use this backup > technique --- but you should find out what that cost is ... All sync writes will hang while the snapshot is beeing taken. Not sure if async writes are buffered in memory or will hang too. So, basicly your database will be inresponsive for the time it takes to take a snapshot. The time will depend on the size of the device, the size of the pysical extents (the LVM "blocks") and the raw disk performance, but typically we're talking about periods shorter than a second. -- Ragnar Kjørstad Zet.no From tgl@sss.pgh.pa.us Mon Mar 17 14:04:45 2003 X-Original-To: pgsql-admin@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A4177475FBA for ; Mon, 17 Mar 2003 09:04:45 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2HE4fub005705; Mon, 17 Mar 2003 09:04:42 -0500 (EST) To: Ragnar =?iso-8859-15?B?S2rDuHJzdGFk?= Cc: Peter Eisentraut , Matt , Murthy Kambhampaty , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: <20030317123132.GC24425@vestdata.no> References: <21197.1047837058@sss.pgh.pa.us> <20030317123132.GC24425@vestdata.no> Comments: In-reply-to Ragnar =?iso-8859-15?B?S2rDuHJzdGFk?= message dated "Mon, 17 Mar 2003 13:31:32 +0100" Date: Mon, 17 Mar 2003 09:04:41 -0500 Message-ID: <5704.1047909881@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/252 X-Sequence-Number: 7892 Ragnar =?iso-8859-15?B?S2rDuHJzdGFk?= writes: > So, basicly your database will be inresponsive for the time it takes to > take a snapshot. The time will depend on the size of the device, the > size of the pysical extents (the LVM "blocks") and the raw disk > performance, but typically we're talking about periods shorter than a > second. We are? On what size database? Surely it takes longer than a second to copy a reasonable-size database. regards, tom lane From matt@ymogen.net Mon Mar 17 14:27:08 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id AE4CE475FBA for ; Mon, 17 Mar 2003 09:27:08 -0500 (EST) Received: (qmail 15347 invoked from network); 17 Mar 2003 14:27:11 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 17 Mar 2003 14:27:11 -0000 From: "Matt Clark" To: "Tom Lane" , =?iso-8859-1?Q?Ragnar_Kj=C3zrstad?= Cc: "Peter Eisentraut" , "Murthy Kambhampaty" , Subject: Re: LVM snapshots Date: Mon, 17 Mar 2003 14:27:06 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <5704.1047909881@sss.pgh.pa.us> X-Archive-Number: 200303/253 X-Sequence-Number: 7893 > Ragnar =?iso-8859-15?B?S2rDuHJzdGFk?= writes: > > So, basicly your database will be inresponsive for the time it takes to > > take a snapshot. The time will depend on the size of the device, the > > size of the pysical extents (the LVM "blocks") and the raw disk > > performance, but typically we're talking about periods shorter than a > > second. > > We are? On what size database? Surely it takes longer than a second to > copy a reasonable-size database. Ah, a misconception. The terminology is confusing. What is stored on the 'snapshot volume' is not a copy of the 'frozen volume', but only the writes to the frozen volume. When the 'snapshot volume' is unmounted those updates then get copied back to the 'frozen volume' which is then unfrozen. The 'snapshot volume' therefore only needs to be big enough to store as much data as will be written to (or rather as many blocks as will be altered on) the frozen volume while the snapshot is in place. So when you take a snapshot there is no data to be copied, and when you release a snapshot some data needs to be written back. Since the data to be copied is nice whole disk blocks and no metadata has to be altered that's a pretty fast operation. From tgl@sss.pgh.pa.us Mon Mar 17 14:32:22 2003 X-Original-To: pgsql-admin@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 56BCC475FEE for ; Mon, 17 Mar 2003 09:32:22 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2HEWJub005945; Mon, 17 Mar 2003 09:32:19 -0500 (EST) To: "Matt Clark" Cc: =?iso-8859-1?Q?Ragnar_Kj=C3zrstad?= , "Peter Eisentraut" , "Murthy Kambhampaty" , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: References: Comments: In-reply-to "Matt Clark" message dated "Mon, 17 Mar 2003 14:27:06 +0000" Date: Mon, 17 Mar 2003 09:32:19 -0500 Message-ID: <5944.1047911539@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/254 X-Sequence-Number: 7894 "Matt Clark" writes: > So when you take a snapshot there is no data to be copied, and when > you release a snapshot some data needs to be written back. Does the write-back preserve the original write ordering? In general, what happens if there's a system crash in this state? What of errors encountered during write-back, eg out of disk space (or is disk space accounting still done in terms of the original volume)? regards, tom lane From matt@ymogen.net Mon Mar 17 14:41:19 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id 0C8D5474E53 for ; Mon, 17 Mar 2003 09:41:19 -0500 (EST) Received: (qmail 20199 invoked from network); 17 Mar 2003 14:41:22 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 17 Mar 2003 14:41:22 -0000 From: "Matt Clark" To: "Tom Lane" Cc: =?iso-8859-1?Q?Ragnar_Kj=C3zrstad?= , "Peter Eisentraut" , "Murthy Kambhampaty" , Subject: Re: LVM snapshots Date: Mon, 17 Mar 2003 14:41:16 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <5944.1047911539@sss.pgh.pa.us> X-Archive-Number: 200303/255 X-Sequence-Number: 7895 Many apologies, I got things completely the wrong way round I think! My fault entirely. The snapshot volume holds the *original* data from the frozen volume, using copy-on-write, so neither taking nor releasing the snapshot involve any copying of data. If you run out of room on the snapshot volume because you've written too much data to the frozen volume then you are buggered, pure and simple. > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: 17 March 2003 14:32 > To: Matt Clark > Cc: Ragnar KjÃzrstad; Peter Eisentraut; Murthy Kambhampaty; > pgsql-admin@postgresql.org > Subject: Re: [ADMIN] LVM snapshots > > > "Matt Clark" writes: > > So when you take a snapshot there is no data to be copied, and when > > you release a snapshot some data needs to be written back. > > Does the write-back preserve the original write ordering? In general, > what happens if there's a system crash in this state? What of errors > encountered during write-back, eg out of disk space (or is disk space > accounting still done in terms of the original volume)? > > regards, tom lane > From tgl@sss.pgh.pa.us Mon Mar 17 14:59:30 2003 X-Original-To: pgsql-admin@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 74196475AE5 for ; Mon, 17 Mar 2003 09:59:30 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2HExRub006140; Mon, 17 Mar 2003 09:59:28 -0500 (EST) To: "Matt Clark" Cc: =?iso-8859-1?Q?Ragnar_Kj=C3zrstad?= , "Peter Eisentraut" , "Murthy Kambhampaty" , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: References: Comments: In-reply-to "Matt Clark" message dated "Mon, 17 Mar 2003 14:41:16 +0000" Date: Mon, 17 Mar 2003 09:59:27 -0500 Message-ID: <6139.1047913167@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/257 X-Sequence-Number: 7897 "Matt Clark" writes: > The snapshot volume holds the *original* data from the frozen volume, > using copy-on-write, so neither taking nor releasing the snapshot > involve any copying of data. Ah, I see: so while the freeze is on, writes to the frozen volume cost about 3x normal (1 write -> 1 read + 2 writes), but establishing and discontinuing the freeze cost nothing. And if you have a crash the volume is still in the proper state. Good. > If you run out of room on the snapshot volume because you've written > too much data to the frozen volume then you are buggered, pure and > simple. No, you only have to drop the freeze; the original volume is not broken. I would wonder though about the datastructure that LVM uses to remember which blocks of the frozen volume have been copied (and where) on the snapshot area. I assume this table lives in kernel memory --- what happens if it gets large? regards, tom lane From matt@ymogen.net Mon Mar 17 15:16:20 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id BFE83474E53 for ; Mon, 17 Mar 2003 10:16:20 -0500 (EST) Received: (qmail 32143 invoked from network); 17 Mar 2003 15:16:24 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 17 Mar 2003 15:16:24 -0000 From: "Matt Clark" To: "Tom Lane" Cc: =?iso-8859-1?Q?Ragnar_Kj=C3zrstad?= , "Peter Eisentraut" , "Murthy Kambhampaty" , Subject: Re: LVM snapshots Date: Mon, 17 Mar 2003 15:16:19 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <6139.1047913167@sss.pgh.pa.us> X-Archive-Number: 200303/258 X-Sequence-Number: 7898 > Ah, I see: so while the freeze is on, writes to the frozen volume cost > about 3x normal (1 write -> 1 read + 2 writes), but establishing and > discontinuing the freeze cost nothing. And if you have a crash the > volume is still in the proper state. Good. I think that should be 1 read + 2 writes for the first write to a given block, but just 1 write from then on. > No, you only have to drop the freeze; the original volume is not broken. Yeah, only the snapshot is damaged > > I would wonder though about the datastructure that LVM uses to remember > which blocks of the frozen volume have been copied (and where) on the > snapshot area. I assume this table lives in kernel memory --- what > happens if it gets large? > /* copy on write tables in disk format */ typedef struct lv_COW_table_disk_v1 { uint64_t pv_org_number; uint64_t pv_org_rsector; uint64_t pv_snap_number; uint64_t pv_snap_rsector; } lv_COW_table_disk_t; Looks like 256 bytes per disk block. At a default LVM block size of 64KB that's a 4MB table for 1GB of dirty blocks, plus whatever hash table overhead there might be. Not much at any rate. From postgres@ragnark.vestdata.no Mon Mar 17 15:26:32 2003 X-Original-To: pgsql-admin@postgresql.org Received: from stine.vestdata.no (stine.vestdata.no [195.204.68.10]) by postgresql.org (Postfix) with ESMTP id AF3B2474E53 for ; Mon, 17 Mar 2003 10:26:32 -0500 (EST) Received: (from ragnark@localhost) by stine.vestdata.no (8.11.6/8.11.6) id h2HFQU102814; Mon, 17 Mar 2003 16:26:30 +0100 Date: Mon, 17 Mar 2003 16:26:30 +0100 From: Ragnar =?iso-8859-15?Q?Kj=F8rstad?= To: Tom Lane Cc: Matt Clark , Peter Eisentraut , Murthy Kambhampaty , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Message-ID: <20030317152630.GB23149@vestdata.no> References: <6139.1047913167@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6139.1047913167@sss.pgh.pa.us> User-Agent: Mutt/1.5.2i X-Archive-Number: 200303/259 X-Sequence-Number: 7899 On Mon, Mar 17, 2003 at 09:59:27AM -0500, Tom Lane wrote: > Ah, I see: so while the freeze is on, writes to the frozen volume cost > about 3x normal (1 write -> 1 read + 2 writes), but establishing and > discontinuing the freeze cost nothing. And if you have a crash the > volume is still in the proper state. Good. I would say it cost practically nothing. The buffers are flushed to disk, and some metadata updated, so there is a small cost. I don't think the 3x write-cost is accurate? What is the read for? There shouldn't be any reads as far as I can tell. (assuming the lvm-metadata is in memory - I think it always is) When you write to a block for the first time (after taking the snapshot) there should be 2 writes - one to write the data, and one to update lvm-metadata. The next time you write to the same "block" there should only be one write. If you use large LVM-blocks (extents) there will be only one write most of the time. (if you do sequential writes). On the other hand, if you do random writes, large extents will waste a lot of disk-space for your snapshot. So, I think the write-cost should be somewhere in the range 1x-2x of non-snapshot cost, depending on your usage. > I would wonder though about the datastructure that LVM uses to remember > which blocks of the frozen volume have been copied (and where) on the > snapshot area. I assume this table lives in kernel memory --- what > happens if it gets large? I believe it has a fixed size. It should take 4 bytes * (volume_size / block_size). LVM-blocksizes are relatively large, 4 MB pr default, and for large volumes it's common to use even bigger blocks (say 128 MB). For a 2TB volume and 128 MB blocks the datastructure should take 32KB memory. -- Ragnar Kjørstad Zet.no From postgres@ragnark.vestdata.no Mon Mar 17 15:31:49 2003 X-Original-To: pgsql-admin@postgresql.org Received: from stine.vestdata.no (stine.vestdata.no [195.204.68.10]) by postgresql.org (Postfix) with ESMTP id DBD36474E53 for ; Mon, 17 Mar 2003 10:31:49 -0500 (EST) Received: (from ragnark@localhost) by stine.vestdata.no (8.11.6/8.11.6) id h2HFVm303215; Mon, 17 Mar 2003 16:31:48 +0100 Date: Mon, 17 Mar 2003 16:31:48 +0100 From: Ragnar =?iso-8859-15?Q?Kj=F8rstad?= To: Matt Clark Cc: Tom Lane , Peter Eisentraut , Murthy Kambhampaty , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Message-ID: <20030317153148.GC23149@vestdata.no> References: <6139.1047913167@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.2i X-Archive-Number: 200303/261 X-Sequence-Number: 7901 On Mon, Mar 17, 2003 at 03:16:19PM -0000, Matt Clark wrote: > > Ah, I see: so while the freeze is on, writes to the frozen volume cost > > about 3x normal (1 write -> 1 read + 2 writes), but establishing and > > discontinuing the freeze cost nothing. And if you have a crash the > > volume is still in the proper state. Good. > > I think that should be 1 read + 2 writes for the first write to a given block, but just 1 write from then on. Ah, the read is needed if you're not writing the full block, right? Discard my email on this topic, then. > > I would wonder though about the datastructure that LVM uses to remember > > which blocks of the frozen volume have been copied (and where) on the > > snapshot area. I assume this table lives in kernel memory --- what > > happens if it gets large? > > /* copy on write tables in disk format */ > typedef struct lv_COW_table_disk_v1 { > uint64_t pv_org_number; > uint64_t pv_org_rsector; > uint64_t pv_snap_number; > uint64_t pv_snap_rsector; > } lv_COW_table_disk_t; > > Looks like 256 bytes per disk block. At a default LVM block size of 64KB that's a 4MB table for 1GB of dirty blocks, plus whatever > hash table overhead there might be. Not much at any rate. I'm confused. First I thought LVM used 32bit block-numbers. Second, I thought 4 MB was the default extent-size. Third, I thought this was a fixed mapping table, not a dynamic table. I must admint it has been a long time since I read the lvm-source, so I may have forgotten or they may have changed it. Is this from LVM1 or LVM2? Is the COW-table different from the regular LVM mapping table? -- Ragnar Kjørstad Zet.no From matt@ymogen.net Mon Mar 17 15:35:54 2003 X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id AD465475FC6 for ; Mon, 17 Mar 2003 10:35:54 -0500 (EST) Received: (qmail 6175 invoked from network); 17 Mar 2003 15:35:58 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 17 Mar 2003 15:35:58 -0000 From: "Matt Clark" To: =?ISO-8859-15?Q?Ragnar_Kj=F8rstad?= , "Tom Lane" Cc: "Peter Eisentraut" , "Murthy Kambhampaty" , Subject: Re: LVM snapshots Date: Mon, 17 Mar 2003 15:35:53 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20030317152630.GB23149@vestdata.no> X-Archive-Number: 200303/262 X-Sequence-Number: 7902 > LVM-blocksizes are relatively large, 4 MB pr default, and for large > volumes it's common to use even bigger blocks (say 128 MB). For a 2TB > volume and 128 MB blocks the datastructure should take 32KB memory. 4MB is the size of a physical extent, not a block. Snapshots use 'chunks' not whole extents, and I don't know what (if any) relationship there is between chunks and blocks. #define LVM_SNAPSHOT_MAX_CHUNK 1024 /* 1024 KB */ #define LVM_SNAPSHOT_DEF_CHUNK 64 /* 64 KB */ #define LVM_SNAPSHOT_MIN_CHUNK (PAGE_SIZE/1024) /* 4 or 8 KB */ Anyway, you definitely *don't* force LVM to copy 4MB of data the first time you touch just 1 bit on a snapshotted volume! From postgres@ragnark.vestdata.no Mon Mar 17 15:39:35 2003 X-Original-To: pgsql-admin@postgresql.org Received: from stine.vestdata.no (stine.vestdata.no [195.204.68.10]) by postgresql.org (Postfix) with ESMTP id 5462C474E53 for ; Mon, 17 Mar 2003 10:39:35 -0500 (EST) Received: (from ragnark@localhost) by stine.vestdata.no (8.11.6/8.11.6) id h2HFdV903688; Mon, 17 Mar 2003 16:39:31 +0100 Date: Mon, 17 Mar 2003 16:39:31 +0100 From: Ragnar =?iso-8859-15?Q?Kj=F8rstad?= To: Matt Clark Cc: Tom Lane , Peter Eisentraut , Murthy Kambhampaty , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Message-ID: <20030317153931.GD23149@vestdata.no> References: <20030317152630.GB23149@vestdata.no> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.2i X-Archive-Number: 200303/264 X-Sequence-Number: 7904 On Mon, Mar 17, 2003 at 03:35:53PM -0000, Matt Clark wrote: > > LVM-blocksizes are relatively large, 4 MB pr default, and for large > > volumes it's common to use even bigger blocks (say 128 MB). For a 2TB > > volume and 128 MB blocks the datastructure should take 32KB memory. > > 4MB is the size of a physical extent, not a block. Snapshots use 'chunks' not whole extents, and I don't know what (if any) > relationship there is between chunks and blocks. > > #define LVM_SNAPSHOT_MAX_CHUNK 1024 /* 1024 KB */ > #define LVM_SNAPSHOT_DEF_CHUNK 64 /* 64 KB */ > #define LVM_SNAPSHOT_MIN_CHUNK (PAGE_SIZE/1024) /* 4 or 8 KB */ Ah, that explains it. Sorry for adding to the confusion. > Anyway, you definitely *don't* force LVM to copy 4MB of data the first time you touch just 1 bit on a snapshotted volume! Probably not. -- Ragnar Kjørstad Zet.no From murthy.kambhampaty@goeci.com Thu Apr 3 00:21:23 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1859E47592C for ; Wed, 2 Apr 2003 19:21:23 -0500 (EST) Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by postgresql.org (Postfix) with ESMTP id E0D01474E44 for ; Wed, 2 Apr 2003 19:21:21 -0500 (EST) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id <2A4GD57P>; Wed, 2 Apr 2003 19:21:24 -0500 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC0921C6@THOR.goeci.com> From: Murthy Kambhampaty To: 'Peter Eisentraut' , Matt Cc: "'pgsql-admin@postgresql.org'" Subject: Re: LVM snapshots Date: Wed, 2 Apr 2003 19:21:18 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C2F976.F20B686A" X-Spam-Status: No, hits=-16.3 required=5.0 tests=BAYES_01,HTML_TAG_BALANCE_TABLE,ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT,SIGNATURE_SHORT_SPARSE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/31 X-Sequence-Number: 8186 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C2F976.F20B686A Content-Type: text/plain; charset="iso-8859-1" Here's what I have so far: The attachment includes a revised version of a script for backing up the database cluster, and the logs from a couple of instances of it; in these instances the server was under the following workload: A script that 1. Copies a roughly 380,000 row and 85 column file into a newly create table called tbl1 2. Creates 3 single column indexes on tlb1 3. In 3 parallel subshells, 3 separate insert ... from select ... queries put data from tbl1 into tbl2, tbl3, and tbl4 4. Upon completion, of step3, tbl1 is dropped and the process is repeated for 12 different text files with distinct data, and similar size 5. 3 single column indexes are added to each of tbl2, tbl3 and tbl4 in 3 parallel subshells Server hardware: Quad PIII Xeon 500 MHz/2MB L2, 6 GB RAM, 168 GB HW RAID5 (data), free space on second 168 GB HW RAID5 for snapshots on a dual channel Mylex Acceleraid 352, with XFS filesystem logs on a LINUX MD1 connected with an Adaptec 39320-R. Column sums on the larger tables on the production server and on the backup server gave identical values. Using a SAS System facility called PROC COMPARE on the smaller tables, they were found to be identical. Note, however, (i) my rsync options get the WHOLE FILE each time a table changes, and (ii) because the logs attached are from tables that are being updated on the production server, the copies of these tables have not been verified for "accuracy", only recoverability (vacuum analyze completes successfully). Therefore, users in transaction processing environments will have to do their own testing. (I have verified that doing incremental rsyncs until the data stabilize is also reliable; I'm just being paranoid on this one, and the cost is not too high.) I have also successfully run the backup simultaneously with the above workload on a Dual PIII 1GHz/512MB L2, 528 MB RAM, 60 GB IDE data here, 6 GB IDE (snapshots here) on the SAME ide channel. This version uses a two-phase rsync: the first rsync copies the live $PGDATA directory, excluding the pg_xlog/ folder, from the production server to the backup server; the second is run on an LVM snapshot of the $PGDATA folder. The postmaster is started and stopped on the backup server, so that any problems can be identified right away. (Notice the "ReadRecord: unexpected pageaddr 13C/98EDA000 in log file 317, segment 11, offset 15572992" in the later log. This seems to be a non-critical error; VACUUM ANALYZE gave a short series of: NOTICE: Rel
: Uninitialized page 54300 - fixing ... VACUUM ). Others have suggested the two-phase rsync, but there the second phase required shutting down the postmaster. Besides the obvious advantage, it turns out that because snapshots are fast -- especially if fsync=true -- the second rsync has little to do (if you turn of --exclude='pg_xlog/' in the first phase, you many find that the backup is fully complete and the snapshot is removed almost immediately after creation). Thus, the time that the snapshot is up and dragging down filesystem operations is minimized. ADDITIONAL NOTES: Data recovery from backup is done with: pg_dump -Fc -h bkHost -U pguser -d db-to-recover [ -t ] | pg_restore -h pgHost -U pguser -c As, the 7.4dev docs say: "WAL offers the opportunity for a new method for database on-line backup and restore (BAR). To use this method, one would have to make periodic saves of data files to another disk, a tape or another host and also archive the WAL log files. The database file copy and the archived log files could be used to restore just as if one were restoring after a crash. Each time a new database file copy was made the old log files could be removed. Implementing this facility will require the logging of data file and index creation and deletion; it will also require development of a method for copying the data files (operating system copy commands are not suitable)." If you can stand doing it with filesystem level tools (LVM or EVMS on linux; hw snapshots on other OS?), you can do this already, as shown here. Besides BAR, here are a couple of applications to consider: 1. A limited form of PITR: You can recover any object to its state at the last snapshot backup. (Of course, log roll-forward is missing.) >From Oracle 9i documentation: "Introduction to RMAN TSPITR Recovery Manager (RMAN) automated tablespace point-in-time recovery (TSPITR) enables you to quickly recover one or more tablespaces to a time that is different from that of the rest of the database. RMAN TSPITR is most useful for recovering the following: * An erroneous DROP TABLE or TRUNCATE TABLE statement * A table that has become logically corrupted * An incorrect batch job or other DML statement that has affected only a subset of the database ... " Can do here. 2. It is much easier to upgrade versions. Initdb the new version on pgHost, then (pg_dumpall -Fc -h bkHost | pg_restore ) from the upgraded server. 3. If $PGDATA/pg_xlog is on a different set of disks than PGDATA, you should be able to adapt with: xfs_freeze -f $PGXLOG_FS xfs_freeze -f $PGDATA_FS lvcreate -s -L -n snap_pgdata lvcreate -s -n -n snap_pgxlog xfs_freeze -u $PGDATA_FS xfs_freeze -u $PGXLOG_FS (on the assumption that the postmaster isn't doing anything while waiting for pg_xlog/ writes to complete). You can then mount the snapshots in the proper places, rsync and go. This has not been tested, though it's on my agenda. Could the postgresql developers comment on this? As Matt points out, this strategy is a useful addition to the postgresql administrator's tools. It seems useful to update the documentation, and to point out that the WAL design already gives the benefit of online backup and restore when combined with externally available snaphsot facilities. QED. Cheers, Murthy -----Original Message----- From: Peter Eisentraut [mailto:peter_e@gmx.net] Sent: Sunday, March 16, 2003 09:05 To: Matt Cc: Murthy Kambhampaty; pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots Matt writes: > If the theory can be robustly demonstrated to work in practice (which > you may have already done) then I say this strategy needs to be > recognised in the docs (or at least the techdocs) as a valid and useful one. The note in the documentation is rather old. If you can conclusively disprove it, then we'll be happy to alter it. -- Peter Eisentraut peter_e@gmx.net ------_=_NextPart_000_01C2F976.F20B686A Content-Type: application/octet-stream; name="pgSnapBack.tgz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pgSnapBack.tgz" H4sIALx6iz4AA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bWFOuIRe6U/99hFOUI1HwSufDVMCwV/2vcWy2/UW87 aPWHg87A0MuzdbVq9vYP2aP+I9CsEPJX0xw8As3SiaimSZagFWcrCv7+N842 t6gte0D5Wm6JdoHBu0rQxCSzPGkrSa3vqnZPs/MINHuPQFN+BJr/NwsamGlO AzMNaWAmehlIDTONaWAmemlLDTPRK0scZlJ/2RDYKiMD6i4bQjUU/7IhVLWj y4ZGwSgYBaNgFIyC4QAALHL/+AB4AAA= ------_=_NextPart_000_01C2F976.F20B686A-- From matt@ymogen.net Fri Apr 4 09:28:36 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 69E92475E82 for ; Fri, 4 Apr 2003 04:28:36 -0500 (EST) Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id 3CFBF475B47 for ; Fri, 4 Apr 2003 04:28:35 -0500 (EST) Received: (qmail 24681 invoked from network); 4 Apr 2003 09:28:35 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 4 Apr 2003 09:28:35 -0000 From: "Matt Clark" To: "Murthy Kambhampaty" , "'Peter Eisentraut'" Cc: Subject: Re: LVM snapshots Date: Fri, 4 Apr 2003 10:27:37 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-reply-to: <2D92FEBFD3BE1346A6C397223A8DD3FC0921C6@THOR.goeci.com> X-Spam-Status: No, hits=-14.8 required=5.0 tests=BAYES_20,HTML_TAG_BALANCE_TABLE,IN_REP_TO, MSGID_GOOD_EXCHANGE,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/48 X-Sequence-Number: 8203 Thanks Murthy, that's exceptionally helpful! Does anyone know what (in general) would cause the notices that Murthy spotted in the logs as per the snippet below? > The postmaster is started and stopped on the backup server, so that any > problems can be identified right away. (Notice the "ReadRecord: unexpected > pageaddr 13C/98EDA000 in log file 317, segment 11, offset 15572992" in the > later log. This seems to be a non-critical error; VACUUM ANALYZE gave a > short series of: > NOTICE: Rel
: Uninitialized page 54300 - fixing > ... > VACUUM > ). From tgl@sss.pgh.pa.us Fri Apr 4 14:49:51 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 60A17475B47 for ; Fri, 4 Apr 2003 09:49:51 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 09485475F5F for ; Fri, 4 Apr 2003 09:49:49 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h34Enh2L005551; Fri, 4 Apr 2003 09:49:45 -0500 (EST) To: "Matt Clark" Cc: "Murthy Kambhampaty" , "'Peter Eisentraut'" , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: References: Comments: In-reply-to "Matt Clark" message dated "Fri, 04 Apr 2003 10:27:37 +0100" Date: Fri, 04 Apr 2003 09:49:43 -0500 Message-ID: <5550.1049467783@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-31.9 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,HTML_TAG_BALANCE_TABLE, IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/52 X-Sequence-Number: 8207 "Matt Clark" writes: > Does anyone know what (in general) would cause the notices that Murthy spotted in the logs as per the snippet below? >> NOTICE: Rel
: Uninitialized page 54300 - fixing There is a known mechanism for this to occur on certain key system catalogs, see http://fts.postgresql.org/db/mw/msg.html?mid=1357214 We've seen some reports suggesting it can happen on user tables too, but I don't know what the mechanism is or whether there's any risk of data loss. If you can make this happen reproducibly (or at least with decent probability) on tables other than pg_class, pg_type, pg_attribute, pg_proc, then I'd be real interested to see a test case. regards, tom lane From murthy.kambhampaty@goeci.com Fri Apr 4 15:09:03 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 29D27475CEE for ; Fri, 4 Apr 2003 10:09:03 -0500 (EST) Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by postgresql.org (Postfix) with ESMTP id 6F7DA475C3D for ; Fri, 4 Apr 2003 10:08:58 -0500 (EST) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id <2A4GD96X>; Fri, 4 Apr 2003 10:09:02 -0500 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC0921CC@THOR.goeci.com> From: Murthy Kambhampaty To: 'Tom Lane' , Matt Clark Cc: Murthy Kambhampaty , 'Peter Eisentraut' , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Date: Fri, 4 Apr 2003 10:09:01 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Status: No, hits=-15.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,HTML_TAG_BALANCE_TABLE, QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/53 X-Sequence-Number: 8208 Tom Lane [mailto:tgl@sss.pgh.pa.us] writes: >>> NOTICE: Rel
: Uninitialized page 54300 - fixing > >There is a known mechanism for this to occur on certain key system catalogs, >see http://fts.postgresql.org/db/mw/msg.html?mid=1357214 > >We've seen some reports suggesting it can happen on user tables too, but >I don't know what the mechanism is or whether there's any risk of data >loss. If you can make this happen reproducibly (or at least with decent >probability) on tables other than pg_class, pg_type, pg_attribute, pg_proc, >then I'd be real interested to see a test case. > > The tables on which this happened were the ones called tbl2 and tbl3 in my example: i.e., tables into which data were being added with "insert into tbl[1,2] from select * from tbl1 where ..." running in parallel subshells. If somebody wants to try to replicate this: 1. Create a table with several hundred thousand records 2. Start an "insert into tbl2 from select ..." (multiple ones in parallel maximize your chance of hitting this) 3. Freeze the filesystem, create a snapshot, unfreeze the filesystem, mount the snapshot and copy $PGDATA somewhere else 4. Start a postmaster on the copy of the database cluster; run VACUUM ANALYZE on tlb2 you should see a series of NOTICE: Rel tbl2: Uninitialized page 'nnnnn' - fixing messages I might have a chance to play with this late next but right now I'm swamped. Cheers, Murthy From tgl@sss.pgh.pa.us Fri Apr 4 18:02:29 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0AD054758E6 for ; Fri, 4 Apr 2003 13:02:29 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 04636474E42 for ; Fri, 4 Apr 2003 13:02:27 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h34I2I2L007902; Fri, 4 Apr 2003 13:02:19 -0500 (EST) To: Murthy Kambhampaty Cc: Matt Clark , "'Peter Eisentraut'" , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: <2D92FEBFD3BE1346A6C397223A8DD3FC0921CC@THOR.goeci.com> References: <2D92FEBFD3BE1346A6C397223A8DD3FC0921CC@THOR.goeci.com> Comments: In-reply-to Murthy Kambhampaty message dated "Fri, 04 Apr 2003 10:09:01 -0500" Date: Fri, 04 Apr 2003 13:02:18 -0500 Message-ID: <7901.1049479338@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/57 X-Sequence-Number: 8212 Murthy Kambhampaty writes: > If somebody wants to try to replicate this: > 1. Create a table with several hundred thousand records > 2. Start an "insert into tbl2 from select ..." (multiple ones in parallel > maximize your chance of hitting this) > 3. Freeze the filesystem, create a snapshot, unfreeze the filesystem, mount > the snapshot and copy $PGDATA somewhere else > 4. Start a postmaster on the copy of the database cluster; run VACUUM > ANALYZE on tlb2 > you should see a series of > NOTICE: Rel tbl2: Uninitialized page 'nnnnn' - fixing > messages Hmm. This amounts to testing what happens after a Postgres crash (the copied PGDATA will look exactly like the system had gone down at the instant of the freeze). In that scenario zeroed pages aren't too improbable, although I wouldn't expect to see a large number of them. Are you running with a nondefault WAL_BUFFERS setting? The way it could happen is like this: you have backend(s) busily extending the table and filling each page with new tuples. Each time we extend a table, we actually write a page of zeroes to the kernel --- this is so that we'll find out right away if we're out of disk space. Then, *inside the Postgres shared-buffer arena*, the page is initialized with correct header data and filled with tuples. Unless you are short on shared buffers, it will probably not be written out to the kernel until the next checkpoint. So there is an interval where the kernel thinks that this page of the file exists but contains zeroes. Meanwhile, WAL entries for the new tuples are being written into the WAL buffers arena. But they aren't going to be forced to disk until there's a transaction commit (or the WAL buffers become full). If the first WAL entry describing a tuple insertion into the new page gets out to disk (or out to the kernel at least) before the filesystem freeze or Postgres crash, then WAL replay will initialize the zeroed page and you won't see any complaints. But there is clearly an interval where a zeroed page can be added to a table and not initialized by WAL replay. This is all okay and no data loss is possible through this mechanism. We can only lose uncommitted tuples, since a commit would have forced out the WAL entries. But it's hard to see how you could have more than approximately WAL_BUFFERS uninitialized pages present due to this scenario --- a WAL entry can remain unwritten only as long as less than WAL_BUFFERS worth of subsequent WAL traffic has occurred, so the physical extensions of the file can't get all that far ahead of what WAL replay will be able to see. If you're just seeing a few of these notices per try, then I don't think there's anything to worry about (especially if they reference pages very near the end of their tables). Otherwise, there may be some other behavior involved, and we'd better look more closely. regards, tom lane From matt@ymogen.net Fri Apr 4 18:21:45 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A1AD7475B99 for ; Fri, 4 Apr 2003 13:21:45 -0500 (EST) Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id DA527475A45 for ; Fri, 4 Apr 2003 13:21:39 -0500 (EST) Received: (qmail 11245 invoked from network); 4 Apr 2003 18:21:38 -0000 Received: from unknown (HELO ymogen.net) (mailuser@194.164.65.208) by 0 with SMTP; 4 Apr 2003 18:21:38 -0000 Message-ID: <3E8DCE84.2060909@ymogen.net> Date: Fri, 04 Apr 2003 19:27:16 +0100 From: Matt User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Murthy Kambhampaty , 'Peter Eisentraut' , pgsql-admin@postgresql.org Subject: Re: LVM snapshots References: <2D92FEBFD3BE1346A6C397223A8DD3FC0921CC@THOR.goeci.com> <7901.1049479338@sss.pgh.pa.us> In-Reply-To: <7901.1049479338@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/60 X-Sequence-Number: 8215 Tom Lane wrote: > A lot of detailed and informative stuff essentially equating a snapshot backup with a system crash And I have to agree with what Tom said. An FS snapshot should indeed look just like an instantaneous halt in processing. Murthy's testing does involve a pretty heavy load, and it is in a sense reassuring that it manages to generate the same kind of issues, and that PostgreSQL's ability to recover from such crashes is so good. Maybe one could use FS snapshots as a way to test crash recovery without needing to crash the system! Anyway, I was about to respond to Tom's comment that it looked like a snapshotting bug, but can we take it from yr subsequent post Tom that you no longer think so? From tgl@sss.pgh.pa.us Fri Apr 4 18:29:08 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2B0F7475B99 for ; Fri, 4 Apr 2003 13:29:08 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 698DC475B47 for ; Fri, 4 Apr 2003 13:29:07 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h34IT02L008122; Fri, 4 Apr 2003 13:29:00 -0500 (EST) To: Matt Cc: Murthy Kambhampaty , "'Peter Eisentraut'" , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: <3E8DCE84.2060909@ymogen.net> References: <2D92FEBFD3BE1346A6C397223A8DD3FC0921CC@THOR.goeci.com> <7901.1049479338@sss.pgh.pa.us> <3E8DCE84.2060909@ymogen.net> Comments: In-reply-to Matt message dated "Fri, 04 Apr 2003 19:27:16 +0100" Date: Fri, 04 Apr 2003 13:29:00 -0500 Message-ID: <8121.1049480940@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/61 X-Sequence-Number: 8216 Matt writes: > Anyway, I was about to respond to Tom's comment that it looked like a > snapshotting bug, but can we take it from yr subsequent post Tom that > you no longer think so? Right, assuming that what Murthy is seeing matches the behavior I described (ie, no more than a few zeroed pages, all near the ends of tables that were undergoing extension). regards, tom lane From murthy.kambhampaty@goeci.com Fri Apr 4 22:32:09 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 13A1D475F53 for ; Fri, 4 Apr 2003 17:32:09 -0500 (EST) Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by postgresql.org (Postfix) with ESMTP id 81C46475EFD for ; Fri, 4 Apr 2003 17:32:07 -0500 (EST) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id <2A4GD067>; Fri, 4 Apr 2003 17:32:09 -0500 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC0921D1@THOR.goeci.com> From: Murthy Kambhampaty To: 'Tom Lane' , Matt Cc: 'Peter Eisentraut' , pgsql-admin@postgresql.org Subject: Re: LVM snapshots Date: Fri, 4 Apr 2003 17:32:08 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Status: No, hits=-13.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/62 X-Sequence-Number: 8217 Tom Lane [mailto:tgl@sss.pgh.pa.us] writes: >> NOTICE: Rel tbl2: Uninitialized page 'nnnnn' - fixing >Hmm. This amounts to testing what happens after a Postgres crash (the >copied PGDATA will look exactly like the system had gone down at the >instant of the freeze). In that scenario zeroed pages aren't too >improbable, although I wouldn't expect to see a large number of them. It turns out there aren't many of them, after all, and they seem to be truncated by vacuum. Here's the vacuum report from the log, for the two files "afftected": 2003-04-02 18:33:46 [4657] DEBUG: --Relation tbl2-- 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54300 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54301 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54302 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54303 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54304 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54305 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54306 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54307 - fixing 2003-04-02 18:34:33 [4657] NOTICE: Rel tbl2: Uninitialized page 54308 - fixing 2003-04-02 18:34:34 [4657] DEBUG: Removed 49173 tuples in 3946 pages. CPU 0.27s/1.07u sec elapsed 1.34 sec. 2003-04-02 18:34:34 [4657] DEBUG: Pages 54309: Changed 54300, Empty 0; Tup 620366: Vac 49173, Keep 0, UnUsed 0. Total CPU 9.78s/2.35u sec elapsed 47.74 sec. 2003-04-02 18:34:35 [4657] DEBUG: Truncated 54309 --> 50355 pages. CPU 0.38s/0.07u sec elapsed 0.44 sec. 2003-04-02 18:34:55 [4657] DEBUG: --Relation tbl3-- 2003-04-02 18:35:31 [4657] NOTICE: Rel tbl3: Uninitialized page 33172 - fixing 2003-04-02 18:35:31 [4657] NOTICE: Rel tbl3: Uninitialized page 33173 - fixing 2003-04-02 18:35:31 [4657] NOTICE: Rel tbl3: Uninitialized page 33174 - fixing 2003-04-02 18:35:31 [4657] NOTICE: Rel tbl3: Uninitialized page 33175 - fixing 2003-04-02 18:35:32 [4657] DEBUG: Removed 38874 tuples in 3230 pages. CPU 0.20s/0.88u sec elapsed 1.08 sec. 2003-04-02 18:35:32 [4657] DEBUG: Pages 33176: Changed 33172, Empty 0; Tup 354316: Vac 38874, Keep 0, UnUsed 0. Total CPU 5.66s/1.71u sec elapsed 36.95 sec. 2003-04-02 18:35:32 [4657] DEBUG: Truncated 33176 --> 29943 pages. CPU 0.41s/0.02u sec elapsed 0.42 sec. >Are you running with a nondefault WAL_BUFFERS setting? WAL_BUFFERS=64 > [ Snip ] Thanks for the explanation, and for taking a second look ;-) From tgl@sss.pgh.pa.us Fri Apr 4 22:34:23 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B87F2476371 for ; Fri, 4 Apr 2003 17:34:23 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0D99347635E for ; Fri, 4 Apr 2003 17:34:21 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h34MYE2L010049; Fri, 4 Apr 2003 17:34:14 -0500 (EST) To: Murthy Kambhampaty Cc: Matt , "'Peter Eisentraut'" , pgsql-admin@postgresql.org Subject: Re: LVM snapshots In-reply-to: <2D92FEBFD3BE1346A6C397223A8DD3FC0921D1@THOR.goeci.com> References: <2D92FEBFD3BE1346A6C397223A8DD3FC0921D1@THOR.goeci.com> Comments: In-reply-to Murthy Kambhampaty message dated "Fri, 04 Apr 2003 17:32:08 -0500" Date: Fri, 04 Apr 2003 17:34:14 -0500 Message-ID: <10048.1049495654@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/63 X-Sequence-Number: 8218 Murthy Kambhampaty writes: >> Are you running with a nondefault WAL_BUFFERS setting? > WAL_BUFFERS=64 Okay, a dozen or so uninitialized pages seem consistent with that setting. I think we understand this one then ... regards, tom lane