Slow PITR restore

Started by Joshua D. Drakeover 18 years ago69 messageshackersgeneral
Jump to latest
#1Joshua D. Drake
jd@commandprompt.com
hackersgeneral

Hello,

I have an interesting thing going on here...

2007-12-11 21:10:36 EST LOG: restored log file
"00000001000007CC00000012" from archive
2007-12-11 21:10:47 EST LOG: restored log file
"00000001000007CC00000013" from archive
2007-12-11 21:11:02 EST LOG: restored log file
"00000001000007CC00000014" from archive
2007-12-11 21:11:14 EST LOG: restored log file
"00000001000007CC00000015" from archive
2007-12-11 21:11:26 EST LOG: restored log file
"00000001000007CC00000016" from archive
2007-12-11 21:11:39 EST LOG: restored log file
"00000001000007CC00000017" from archive
2007-12-11 21:11:54 EST LOG: restored log file
"00000001000007CC00000018" from archive
2007-12-11 21:12:13 EST LOG: restored log file
"00000001000007CC00000019" from archive
2007-12-11 21:12:27 EST LOG: restored log file
"00000001000007CC0000001A" from archive
2007-12-11 21:12:42 EST LOG: restored log file
"00000001000007CC0000001B" from archive
2007-12-11 21:12:54 EST LOG: restored log file
"00000001000007CC0000001C" from archive
2007-12-11 21:13:08 EST LOG: restored log file
"00000001000007CC0000001D" from archive
2007-12-11 21:13:21 EST LOG: restored log file
"00000001000007CC0000001E" from archive
2007-12-11 21:13:36 EST LOG: restored log file
"00000001000007CC0000001F" from archive
2007-12-11 21:13:45 EST LOG: restored log file
"00000001000007CC00000020" from archive
2007-12-11 21:13:52 EST LOG: restored log file
"00000001000007CC00000021" from archive
2007-12-11 21:14:01 EST LOG: restored log file
"00000001000007CC00000022" from archive

Now I understand that restoring log files can be slow but this is a big
machine.

32Gig of Ram
28 Disks (two volumes each raid 10)
Using two different table spaces (over each volume)
8 Opterons.

The machine has a production configuration that can doing several
hundred thousand transactions an hour without so much as having to
stretch first. It seems to me that this machine should be *cranking*
through these transactions. Am I just being my usual uptight, impatient
self?

Sincerely,

Joshua D. Drake

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joshua D. Drake (#1)
hackersgeneral
Re: Slow PITR restore

"Joshua D. Drake" <jd@commandprompt.com> writes:

... Now I understand that restoring log files can be slow but this is a big
machine.

Yeah, restoring is known to be less than speedy, because essentially
zero optimization work has been done on it.

Heikki has improved matters a bit in 8.3, but I suspect it's still
not great.

regards, tom lane

#3Joshua D. Drake
jd@commandprompt.com
In reply to: Tom Lane (#2)
hackersgeneral
Re: Slow PITR restore

Tom Lane wrote:

"Joshua D. Drake" <jd@commandprompt.com> writes:

... Now I understand that restoring log files can be slow but this is a big
machine.

Yeah, restoring is known to be less than speedy, because essentially
zero optimization work has been done on it.

Heikki has improved matters a bit in 8.3, but I suspect it's still
not great.

Wow, o.k. well it is something we (the community) really should look at
for 8.4. I am surprised that it is slower than just walking through the
xlogs on recovery. I am sure there is a reason just surprised.

Thanks for answering.

Sincerely,

Joshua D. Drake

Show quoted text

regards, tom lane

#4Bruce Momjian
bruce@momjian.us
In reply to: Joshua D. Drake (#3)
hackersgeneral
Re: Slow PITR restore

"Joshua D. Drake" <jd@commandprompt.com> writes:

Wow, o.k. well it is something we (the community) really should look at for
8.4. I am surprised that it is slower than just walking through the xlogs on
recovery. I am sure there is a reason just surprised.

Well in the worst case it has to do nearly as much work as the original
database did. And it only gets to use 1 cpu so it can only have one i/o
request pending.

bgwriter is started already when doing recovery, right? Perhaps things could
be helped by telling bgwriter to behave differently during recovery.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

#5Simon Riggs
simon@2ndQuadrant.com
In reply to: Bruce Momjian (#4)
hackersgeneral
Re: Slow PITR restore

On Wed, 2007-12-12 at 08:55 +0000, Gregory Stark wrote:

"Joshua D. Drake" <jd@commandprompt.com> writes:

Wow, o.k. well it is something we (the community) really should look at for
8.4. I am surprised that it is slower than just walking through the xlogs on
recovery. I am sure there is a reason just surprised.

It's the same speed because it is the same recovery code.

Well in the worst case it has to do nearly as much work as the original
database did. And it only gets to use 1 cpu so it can only have one i/o
request pending.

That need only be slow in certain circumstances.

bgwriter is started already when doing recovery, right? Perhaps things could
be helped by telling bgwriter to behave differently during recovery.

It would certainly help if bgwriter came up earlier. I've been looking
at that just recently. The main issue is how to structure the code to
tell bgwriter when it can start processing in recovery mode and then
move into normal mode.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#4)
hackersgeneral
Re: Slow PITR restore

Gregory Stark wrote:

bgwriter is started already when doing recovery, right? Perhaps things could
be helped by telling bgwriter to behave differently during recovery.

No.

--
Alvaro Herrera http://www.flickr.com/photos/alvherre/
"Amanece. (Ignacio Reyes)
El Cerro San Crist�bal me mira, c�nicamente, con ojos de virgen"

#7Simon Riggs
simon@2ndQuadrant.com
In reply to: Tom Lane (#2)
hackersgeneral
Re: Slow PITR restore

On Tue, 2007-12-11 at 22:21 -0500, Tom Lane wrote:

"Joshua D. Drake" <jd@commandprompt.com> writes:

... Now I understand that restoring log files can be slow but this is a big
machine.

Yeah, restoring is known to be less than speedy, because essentially
zero optimization work has been done on it.

If there was a patch to improve this, would it be applied to 8.3?

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#8Joshua D. Drake
jd@commandprompt.com
In reply to: Simon Riggs (#7)
hackersgeneral
Re: Slow PITR restore

Simon Riggs wrote:

On Tue, 2007-12-11 at 22:21 -0500, Tom Lane wrote:

"Joshua D. Drake" <jd@commandprompt.com> writes:

... Now I understand that restoring log files can be slow but this is a big
machine.

Yeah, restoring is known to be less than speedy, because essentially
zero optimization work has been done on it.

If there was a patch to improve this, would it be applied to 8.3?

Sheesh Simon you are really pushing this release :). I would love to see
a patch to resolve this, especially since it appears to be a fairly
glaring oversight. We can't really expect people to use PITR if they new
it would take hours to recover even on the size of machine I was working on.

On the other hand... we are about to go to RC1 :)

Joshua D. Drake

#9Simon Riggs
simon@2ndQuadrant.com
In reply to: Joshua D. Drake (#8)
hackersgeneral
Re: Slow PITR restore

On Wed, 2007-12-12 at 07:36 -0800, Joshua D. Drake wrote:

We can't really expect people to use PITR if they new
it would take hours to recover even on the size of machine I was working on.

That's not true statement in all cases and can often be improved with
some monitoring and tuning. Just get your client to call me :-)

Are you doing replication, or a PITR for another reason?

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#10Joshua D. Drake
jd@commandprompt.com
In reply to: Simon Riggs (#9)
hackersgeneral
Re: Slow PITR restore

Simon Riggs wrote:

On Wed, 2007-12-12 at 07:36 -0800, Joshua D. Drake wrote:

We can't really expect people to use PITR if they new
it would take hours to recover even on the size of machine I was working on.

That's not true statement in all cases and can often be improved with
some monitoring and tuning. Just get your client to call me :-)

Uhh.. right.

Are you doing replication, or a PITR for another reason?

Warm standby. Normally we pull every 5 minutes which is why we hadn't
noticed this before. However last night we pulled a full sync and
recover and that is when we noticed it.

8 seconds for a single archive recovery is very slow in consideration of
this machine. Even single threaded that seems slow.

Sincerely,

Joshua D. Drake

#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: Simon Riggs (#7)
hackersgeneral
Re: Slow PITR restore

Simon Riggs <simon@2ndquadrant.com> writes:

On Tue, 2007-12-11 at 22:21 -0500, Tom Lane wrote:

Yeah, restoring is known to be less than speedy, because essentially
zero optimization work has been done on it.

If there was a patch to improve this, would it be applied to 8.3?

Good grief, no. We have not even done the research to find out where
the bottleneck(s) is/are. We're not holding up 8.3 while we go back
into development mode, especially not when this problem has existed
for seven or eight years (even if JD failed to notice before) and
there are already some improvements for it in 8.3.

regards, tom lane

#12Joshua D. Drake
jd@commandprompt.com
In reply to: Tom Lane (#11)
hackersgeneral
Re: Slow PITR restore

Tom Lane wrote:

Simon Riggs <simon@2ndquadrant.com> writes:

On Tue, 2007-12-11 at 22:21 -0500, Tom Lane wrote:

Yeah, restoring is known to be less than speedy, because essentially
zero optimization work has been done on it.

If there was a patch to improve this, would it be applied to 8.3?

Good grief, no. We have not even done the research to find out where
the bottleneck(s) is/are. We're not holding up 8.3 while we go back
into development mode, especially not when this problem has existed
for seven or eight years (even if JD failed to notice before) and
there are already some improvements for it in 8.3.

I would also note that this "problem" is only going to be noticeable on
the highest velocity of databases. This is certainly a 10% of the users
issue. It would be great to get it fixed but there are ways around it
(namely making sure you are running pg_standby and pushing logs at
smaller intervals).

Sincerely,

Joshua D. Drake

Show quoted text

regards, tom lane

#13Simon Riggs
simon@2ndQuadrant.com
In reply to: Tom Lane (#11)
hackersgeneral
Re: Slow PITR restore

On Wed, 2007-12-12 at 12:13 -0500, Tom Lane wrote:

Simon Riggs <simon@2ndquadrant.com> writes:

On Tue, 2007-12-11 at 22:21 -0500, Tom Lane wrote:

Yeah, restoring is known to be less than speedy, because essentially
zero optimization work has been done on it.

If there was a patch to improve this, would it be applied to 8.3?

Good grief, no.

Understood.

Just checking to see if you were fishing for a patch from me, so I'm
relieved actually.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#14Jeff
threshar@torgo.978.org
In reply to: Joshua D. Drake (#10)
hackersgeneral
Re: Slow PITR restore

On Dec 12, 2007, at 11:29 AM, Joshua D. Drake wrote:

8 seconds for a single archive recovery is very slow in
consideration of this machine. Even single threaded that seems slow.

I've seen this on my PITR restores (thankfully, they were for
fetching some old data, not because we expoded). On a 2.4ghz opteron
it took 5-50 seconds per wal segment, and there were a LOT of
segments (replay took hours and hours). I asked a few folks and was
told it is the nature of the beast. Hopefully something in 8.4 can
be done.

--
Jeff Trout <jeff@jefftrout.com>
http://www.dellsmartexitin.com/
http://www.stuarthamm.net/

#15Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jeff (#14)
hackersgeneral
Re: Slow PITR restore

Jeff Trout <threshar@threshar.is-a-geek.com> writes:

I've seen this on my PITR restores (thankfully, they were for
fetching some old data, not because we expoded). On a 2.4ghz opteron
it took 5-50 seconds per wal segment, and there were a LOT of
segments (replay took hours and hours). I asked a few folks and was
told it is the nature of the beast. Hopefully something in 8.4 can
be done.

Before we get all panicked about that, someone should try to measure the
restore speed on 8.3. It's possible that this patch already
alleviated the problem:
http://archives.postgresql.org/pgsql-committers/2007-05/msg00041.php

regards, tom lane

#16Bruce Momjian
bruce@momjian.us
In reply to: Jeff (#14)
hackersgeneral
Re: Slow PITR restore

"Jeff Trout" <threshar@torgo.978.org> writes:

On Dec 12, 2007, at 11:29 AM, Joshua D. Drake wrote:

8 seconds for a single archive recovery is very slow in consideration of
this machine. Even single threaded that seems slow.

I've seen this on my PITR restores (thankfully, they were for fetching some
old data, not because we expoded). On a 2.4ghz opteron it took 5-50 seconds
per wal segment,

I'm not sure what you guys' expectations are, but if you're restoring 5
minutes worth of database traffic in 8 seconds I wouldn't be complaining.

Depending on your transaction mix and what percentage of it is read-only
select queries you might reasonably expect the restore to take as long as it
took to generate them...

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!

#17Joshua D. Drake
jd@commandprompt.com
In reply to: Bruce Momjian (#16)
hackersgeneral
Re: Slow PITR restore

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 12 Dec 2007 18:02:39 +0000
Gregory Stark <stark@enterprisedb.com> wrote:

I'm not sure what you guys' expectations are, but if you're restoring
5 minutes worth of database traffic in 8 seconds I wouldn't be
complaining.

I would be. This is a database that is doing nothing but restoring.
Zero concurrency. This thing should be flying.

Depending on your transaction mix and what percentage of it is
read-only select queries you might reasonably expect the restore to
take as long as it took to generate t

We archive selects?

Joshua D. Drake

- --
The PostgreSQL Company: Since 1997, http://www.commandprompt.com/
Sales/Support: +1.503.667.4564 24x7/Emergency: +1.800.492.2240
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
SELECT 'Training', 'Consulting' FROM vendor WHERE name = 'CMD'

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHYCOIATb/zqfZUUQRAlbBAJ0aNmWy8xFKtmaONUmL9LegTfaaywCfSoS3
TRmDPUEhoTJJVSO8REM6YYI=
=bv/t
-----END PGP SIGNATURE-----

#18Jeff
threshar@torgo.978.org
In reply to: Bruce Momjian (#16)
hackersgeneral
Re: Slow PITR restore

On Dec 12, 2007, at 1:02 PM, Gregory Stark wrote:

I'm not sure what you guys' expectations are, but if you're
restoring 5
minutes worth of database traffic in 8 seconds I wouldn't be
complaining.

Depending on your transaction mix and what percentage of it is read-
only
select queries you might reasonably expect the restore to take as
long as it
took to generate them...

in this case it was 24hrs of data - about 1500 wal segments. During
this time the machine was nearly complete idle and there wasn't very
much IO going on (few megs/sec).

I'll have to artifically build up some db traffic on an 8.3 instance
to see if the patch Tom mentioned helps.

--
Jeff Trout <jeff@jefftrout.com>
http://www.dellsmartexitin.com/
http://www.stuarthamm.net/

#19Simon Riggs
simon@2ndQuadrant.com
In reply to: Joshua D. Drake (#17)
hackersgeneral
Re: Slow PITR restore

On Wed, 2007-12-12 at 10:08 -0800, Joshua D. Drake wrote:

Depending on your transaction mix and what percentage of it is
read-only select queries you might reasonably expect the restore to
take as long as it took to generate t

We archive selects?

No, but that is exactly his point.

Whatever proportion of the workload is selects will *not* have to be
reproduced on the client.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#20Simon Riggs
simon@2ndQuadrant.com
In reply to: Tom Lane (#15)
hackersgeneral
Re: Slow PITR restore

On Wed, 2007-12-12 at 12:56 -0500, Tom Lane wrote:

Jeff Trout <threshar@threshar.is-a-geek.com> writes:

I've seen this on my PITR restores (thankfully, they were for
fetching some old data, not because we expoded). On a 2.4ghz opteron
it took 5-50 seconds per wal segment, and there were a LOT of
segments (replay took hours and hours). I asked a few folks and was
told it is the nature of the beast. Hopefully something in 8.4 can
be done.

Before we get all panicked about that, someone should try to measure the
restore speed on 8.3. It's possible that this patch already
alleviated the problem:
http://archives.postgresql.org/pgsql-committers/2007-05/msg00041.php

Twas this feature, amongst others, that I had asked to be put back onto
the release notes, so people knew it had improved. I don't really want
to replicate that discussion, but if we're talking about it here then it
probably should be in the notes.

It roughly doubles performance, but there's still more required in some
cases. My recommendation is always measure the performance first.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#21Joshua D. Drake
jd@commandprompt.com
In reply to: Jeff (#18)
hackersgeneral
#22Bruce Momjian
bruce@momjian.us
In reply to: Joshua D. Drake (#17)
hackersgeneral
#23Joshua D. Drake
jd@commandprompt.com
In reply to: Bruce Momjian (#22)
hackersgeneral
#24Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joshua D. Drake (#21)
hackersgeneral
#25Joshua D. Drake
jd@commandprompt.com
In reply to: Tom Lane (#24)
hackersgeneral
#26Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#24)
hackersgeneral
#27Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joshua D. Drake (#25)
hackersgeneral
#28Joshua D. Drake
jd@commandprompt.com
In reply to: Tom Lane (#27)
hackersgeneral
#29Simon Riggs
simon@2ndQuadrant.com
In reply to: Bruce Momjian (#26)
hackersgeneral
#30Bruce Momjian
bruce@momjian.us
In reply to: Simon Riggs (#29)
hackersgeneral
#31Simon Riggs
simon@2ndQuadrant.com
In reply to: Bruce Momjian (#30)
hackersgeneral
#32Bruce Momjian
bruce@momjian.us
In reply to: Simon Riggs (#31)
hackersgeneral
#33Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Bruce Momjian (#32)
hackersgeneral
#34Guillaume Smet
guillaume.smet@gmail.com
In reply to: Simon Riggs (#31)
hackersgeneral
#35Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#30)
hackersgeneral
#36Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Simon Riggs (#31)
hackersgeneral
#37Simon Riggs
simon@2ndQuadrant.com
In reply to: Heikki Linnakangas (#33)
hackersgeneral
#38Simon Riggs
simon@2ndQuadrant.com
In reply to: Alvaro Herrera (#35)
hackersgeneral
#39Joshua D. Drake
jd@commandprompt.com
In reply to: Joshua D. Drake (#28)
hackersgeneral
#40Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Simon Riggs (#37)
hackersgeneral
#41Simon Riggs
simon@2ndQuadrant.com
In reply to: Heikki Linnakangas (#40)
hackersgeneral
#42Simon Riggs
simon@2ndQuadrant.com
In reply to: Simon Riggs (#41)
hackersgeneral
#43Tom Lane
tgl@sss.pgh.pa.us
In reply to: Heikki Linnakangas (#40)
hackersgeneral
#44Greg Smith
gsmith@gregsmith.com
In reply to: Bruce Momjian (#26)
hackersgeneral
#45Joshua D. Drake
jd@commandprompt.com
In reply to: Joshua D. Drake (#39)
hackersgeneral
#46Simon Riggs
simon@2ndQuadrant.com
In reply to: Tom Lane (#43)
hackersgeneral
#47Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Tom Lane (#43)
hackersgeneral
#48Tom Lane
tgl@sss.pgh.pa.us
In reply to: Heikki Linnakangas (#47)
hackersgeneral
#49Bruce Momjian
bruce@momjian.us
In reply to: Heikki Linnakangas (#40)
hackersgeneral
#50Josh Berkus
josh@agliodbs.com
In reply to: Tom Lane (#48)
hackersgeneral
#51Tom Lane
tgl@sss.pgh.pa.us
In reply to: Josh Berkus (#50)
hackersgeneral
#52Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#51)
hackersgeneral
#53Markus Wanner
markus@bluegap.ch
In reply to: Alvaro Herrera (#36)
hackersgeneral
#54Zeugswetter Andreas ADI SD
Andreas.Zeugswetter@s-itsolutions.at
In reply to: Greg Smith (#44)
hackersgeneral
#55Simon Riggs
simon@2ndQuadrant.com
In reply to: Zeugswetter Andreas ADI SD (#54)
hackersgeneral
#56Hannu Krosing
hannu@tm.ee
In reply to: Markus Wanner (#53)
hackersgeneral
#57Hannu Krosing
hannu@tm.ee
In reply to: Heikki Linnakangas (#40)
hackersgeneral
#58Markus Wanner
markus@bluegap.ch
In reply to: Hannu Krosing (#56)
hackersgeneral
#59Markus Wanner
markus@bluegap.ch
In reply to: Hannu Krosing (#57)
hackersgeneral
#60Greg Smith
gsmith@gregsmith.com
In reply to: Zeugswetter Andreas ADI SD (#54)
hackersgeneral
#61Wes
wespvp@msg.bt.com
In reply to: Tom Lane (#24)
hackersgeneral
#62Tom Lane
tgl@sss.pgh.pa.us
In reply to: Wes (#61)
hackersgeneral
#63Wes
wespvp@msg.bt.com
In reply to: Tom Lane (#62)
hackersgeneral
#64Bruce Momjian
bruce@momjian.us
In reply to: Wes (#63)
hackersgeneral
#65Wes
wespvp@msg.bt.com
In reply to: Bruce Momjian (#64)
hackersgeneral
#66Wes
wespvp@msg.bt.com
In reply to: Tom Lane (#62)
hackersgeneral
#67Vick Khera
vivek@khera.org
In reply to: Wes (#66)
hackersgeneral
#68Wes
wespvp@msg.bt.com
In reply to: Vick Khera (#67)
hackersgeneral
#69Tom Lane
tgl@sss.pgh.pa.us
In reply to: Wes (#68)
hackersgeneral